• Resolved Ditto Dito

    (@ditto-dito)


    I am astonished to see that the ALT tag of an image is not copied into a new language.

    I checked into admin-filters-media.php, function translate_media(), and see that the postmeta ‘_wp_attachment_image_alt’ is not copied. I don’t see any mechanism to handle custom fields neither.

    I can’t imagine that this is a bug or ommission, but then I have to assume that there is a (better) way to handle this.

    Any hints, please?

    Thanks!

    https://ww.wp.xz.cn/plugins/polylang/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Chouby

    (@chouby)

    Hi!

    The ALT tag is not copied because it is expected to be translated.

    Thread Starter Ditto Dito

    (@ditto-dito)

    Thanks for getting back to me. Still, that feels wrong to me: When I create a new language for an image, everything is copied, except ALT.

    So why ‘caption’ and ‘description’ _is_ copied, when they usually are expected to be translated as well.

    Similar with custom fields to attachments. Looking at the documentation of WPML, you can set these to “copy” or “translate”. Copy means they are always loaded from the original language, Translate means, well translate.

    I any case, I find it better, more natural, to fill in copied language items as much as possible to
    a/ help the translator with content and context
    b/ have at least something to show, even if not translated yet.

    Not a big deal anyway. I have added stuff to my translate_media() :
    if($meta = get_post_meta($post_id, ‘_wp_attachment_image_alt’, true)) add_post_meta($tr_id, ‘_wp_attachment_image_alt’, $meta);
    if($meta = get_post_meta($post_id, ‘_vu_image_tags’, true)) add_post_meta($tr_id, ‘_vu_image_tags’, $meta);
    if($meta = get_post_meta($post_id, ‘_vu_product_sku’, true)) add_post_meta($tr_id, ‘_vu_product_sku’, $meta);

    Plugin Author Chouby

    (@chouby)

    Yes I agree. It lacks consistence. I will copy the alt text too.

    Thread Starter Ditto Dito

    (@ditto-dito)

    Just downloaded the beta2 and saw it’s in already. Great!

    Just out of pure curiosity: I see you trigger ‘pll_translate_media’ after having saved the translations. Not that I know anything about it, but doesn’t that mean that any changes from hooks are not saved?

    Ultimately, that could be good or bad. I am just wondering.

    Plugin Author Chouby

    (@chouby)

    doesn’t that mean that any changes from hooks are not saved?

    What do you mean exactly?

    Thread Starter Ditto Dito

    (@ditto-dito)

    Sorry, I have been re-reading the code and I figure I got that wrong. I assumed that the hooks would possibly modify the $translation variable. But that’s clearly nonsense. Just drop that.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Image ALT tag’ is closed to new replies.