Problem/Motivation

I'm using a 'Leaflet map' formater for my Geofield field.
When using token in the iconsrc path (as gps-[node:nid]), the token is replaced by its value.
When using token in the icon class name (also as gps-[node:nid]), it's not.

Formater setting:
Formater settings

Icon html output :
<img src="https://mysite.ddev.site/themes/custom/mysitetheme/build/assets/icons/gps-21.svg" class="leaflet-marker-icon gps-[node:nid] leaflet-zoom-animated leaflet-interactive" style="margin-left: -15px; margin-top: -43px; width: 30px; height: 43px; transform: translate3d(558px, 200px, 0px); z-index: 200; outline-style: none;" alt="" tabindex="0" role="button">

CommentFileSizeAuthor
SCR-20251028-nywr.jpg125.89 KBphily

Issue fork leaflet-3554815

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

phily created an issue. See original summary.

phily’s picture

Proposed resolution

In src/Plugin/Field/FieldFormatter/LeafletDefaultFormatter.php file @line 462

      $feature['className'] = !empty($settings['className']) ?
        htmlspecialchars_decode(str_replace([
          "\n",
          "\r",
        ], "", $this->token->replace($settings['className'], $tokens)
        )) : '';

should be written

      $feature['icon']['className'] = !empty($settings['icon']['className']) ?
        htmlspecialchars_decode(str_replace([
          "\n",
          "\r",
        ], "", $this->token->replace($settings['icon']['className'], $tokens)
        )) : '';

itamair’s picture

Title: Token in icon class name not replaced by value » Token in icon class name not replaced by value in LeafletFormatter

  • itamair committed f1843cd0 on 10.3.x
    [#3554815] feat: Token in icon class name not replaced by value in...

santanu mondal’s picture

Assigned: Unassigned » santanu mondal
itamair’s picture

Assigned: santanu mondal » Unassigned
Status: Active » Fixed

Thanks @phily ... nice catch.
Latest commit from mine (that slightly extended your MR): https://git.drupalcode.org/project/leaflet/-/commit/f1843cd010d81b8eddf0...
and new 10.3.11 Leaflet module release fix all this.

Regards.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.