Hi, I've embedded several images in a node using Media and Media button.
The images are linked to their content/entity.
The images display ok but I also need to add an attribute to their links (the FID) so I thought overriding theme_link() would achieve this.
It turns out that it only works if I flush cache.
If I save the node and go view it, the attribute is not added.
If I flush all caches and view the node, the attribute is there.

Steps to reproduce:
Override theme_link in your code and add any attribute to the link (based on the linked entity)
Insert image into node with wysiwyg and media button
View node (attribute not added)
Flush all caches
View node (attribute is there)

Drupal 7.24
Media 7.x-2.0-alpha3+5-dev
File Entity 7.x-2.0-alpha3+5-dev

Comments

cato’s picture

That's what you get for making typos and not reading source code properly...

To get the fid attribute on the links I added the following override function in a custom module:

function MYMODULE_media_wysiwyg_token_to_markup_alter(&$element, $tag_info, $settings)
{
    $element['content']['file']['#path']['options']['attributes']['fid'] = $element['content']['file']['#item']['fid'];
}

This could also be used to add accessibility options on the links such as titles and other goodies.

cato’s picture

Assigned: Unassigned » cato
Status: Active » Closed (works as designed)

Assigning to me, marking as WAD and closing.