• synthezoid

    (@synthezoid)


    It’s a seriously major pain that this gallery won’t let me use Alt text as captions. I have hundreds of images with the captions in the Alt text, because wordpress has four, count ’em, four different fields for describing the content of an image: title, description, alt, and caption. And I have another plugin that needs the info in Alt so that’s where I put it before discovering, too late, that Photonic doesn’t see that field. And WP, intelligently, doesn’t give you any way at all to copy data from one of those fields to another. (Yes, I’m aware of the Media Library Assistant plugin, which is completely broken and wasted several hours of my time before I gave up on trying to use it.) It would have made my night a whole lot easier if this plugin would just let me choose the Alt text, rather than only “caption/description” or “title”, as the caption. Thanks.

    • This topic was modified 9 months ago by synthezoid.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Sayontan Sinha

    (@sayontan)

    This would take a bit of time for me to offer as an option, due to testing it alongside other in-flight changes.

    However, if you are comfortable using child themes, then there is a filter hook built into Photonic for this specific purpose. The filter hook is photonic_modify_title, and you could use it this way in a child theme’s functions.php file:

    add_filter('photonic_modify_title', 'photonic_modify_native_titles', 10, 2);
    
    function photonic_modify_native_titles($title, $attachment) {
    	$alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
    	if (!empty($alt)) {
    		return $alt;
    	}
    	return $title;
    }
    

    The above is upgrade-safe, and will remain untouched when you move to newer versions of Photonic.

    The alternative would be to wait for me to add this option to the code (should take a couple of weeks).

    Plugin Author Sayontan Sinha

    (@sayontan)

    BTW, the solution I gave you in my post above is not very performance-compliant.

    The issue (and partly the reason why alt is not built into the WordPress galleries within Photonic) is that the alt value is not returned by the standard call that fetches gallery data. Instead, an additional call is required for this (which is what my code above does). However, standard WP functions don’t let you do bulk-querying of alt data, so, the query will be executed individually for every item of your gallery. That is quite a high number of calls.

    Optimizing this takes a little more effort, wherein all the alt attributes will be fetched in one go. I will include the optimized code in the next version, but for now, please use the above if you are comfortable with child themes.

    Thread Starter synthezoid

    (@synthezoid)

    Thanks for the quick and informative answer. I think your performance concerns are valid, as I looked into this I realized the idiosyncratic under-the-hood architecture of how WP handles these things isn’t so great. I just went ahead and did the work to manually copy all the alt tags into the Description fields, ultimately it was the least-bad solution.

    I’d say, given the performance issue, maybe this isn’t such a high-priority request after all. It’s unfortunate that things are the way they are, but the fault is WP’s, not yours.

    I could maybe imagine a complicated scheme where maybe you cache a block of alt tags as transient or something to save calls, but I could see that being a lot of complicated work for not much benefit, and still not a guaranteed performance gain, as you never even know when transients will get cleared.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Need to use Alt text as caption’ is closed to new replies.