Modifying html from item_image() to customize alt text


Hi. I’m developing a plugin to customize what metadata is used to generate the alt-text for images on Omeka in order to enhance Omeka’s accessibility. With the file_markup filter, it was simple to take the $html, replace the alt-text section of the string, and return it with the changes. However, the changes are only effective on file/show pages because that is the only place file_markup() is called.

The function item_image is used to generate the alt text for almost all image items. It calls image_tag() directly in FileMarkup.php instead of calling the file_markup() function, so the changes made to the $html my file_markup filter are bypassed.

Are there any methods to use a filter to modify the html code returned by image_tag() in FileMarkup.php, any suggestions to modifying the data image_tag() returns through a plugin, or any other approaches I could take to customize the alt-text for images?

Thank you!


Unfortunately, there really isn’t a way to get at the “simple” image output from image_tag… as a somewhat internal part of the fileMarkup helper it doesn’t have extension points of its own, and since it’s referenced directly by the functions that are using it in this way, you can’t even use the Zend Framework system that would let you replace the helper itself with a different implementation.

We can look to add a hook or filter directly there in the future, but that wouldn’t help you now. Are you focused on the admin or public side? (Or both, perhaps.) The public side is easier to deal with since themes can just directly pass the desired alt attribute into the function rendering the image tag.


Thank you for taking the time to respond to my question as I’m fairly new to Omeka and have just started working with plugin development.

Using themes to directly pass the alt attribute into the function rendering the image tag sounds like it could work for the most part. However, I’m hoping to develop a theme-independent solution that works both on the admin and public side for images. I’m also developing a form for the admin side that lets users customize what metadata is used for the alt-text.

Since there’s not a straightforward way to filter image_tag, do you have any ideas of other approaches to this problem?

Thanks again for your help!


The only way I can think of at the moment to get this to work without theme changes is to make changes to the core to allow that. This also means you’d have to wait for a future release for the plugin to work, of course. A filter for attributes right in image_tag is probably the simplest option, but if you’ve got a different proposal I’d be glad to hear it.


Hi @jflatnes. Sorry to revive an old thread, but we are still interested in being able to filter alt text across all thumbnails, and haven’t been able to figure out a different proposal to do it without modifying theme files. Would you all still be open to considering a filter for attributes in image_tag() in a future core update? Should we file an issue on the repo?



Sure, I still think it’s a good idea. Go ahead and file an issue. (Of course, feel free to do so without my say-so too)