• Resolved jpmanson

    (@jpmanson)


    Hello,

    We are using a custom block on our site, the custom block uses a field type “Image”.

    We are also using the Polylang plugin for translations, and we are translating Media, so we can have translations of the image’s captions, descriptions, etc.

    The issue we are having is that even thou we select the translated images in our custom block, they still show the “untranslated” caption. We would like to show the translated image with its translated caption.

    In the block template we are using the tag <?php block_field( 'work-image' ); ?>.

    We searched the plugin’s documentation and forums, but we couldn’t find another tag for images, or any references on how to use translated images with custom blocks.

    Is there a way that we can display the translated images, with the translated captions, in our custom blocks? Please advise.

    Thank you in advance for your help. Kind regards : )

    JP

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor Ryan Kienstra

    (@ryankienstra)

    Hi @jpmanson,
    Thanks a lot for letting me know.

    block_value( 'work-image' ) will get the image (attachment) ID. Would that help to get the translated caption?

    Thread Starter jpmanson

    (@jpmanson)

    Hi @ryankienstra thank you for your reply.

    I tried using block_value('work-image') and the result is the same. Even thou I selected the translated image, when I go to the front I see the image’s caption (and name, etc.) in its original language.

    Please let me know if there’s anything else we can try.

    Thank you again for your help with this. Kind regards,

    JP

    Plugin Contributor Ryan Kienstra

    (@ryankienstra)

    Hi @jpmanson,
    Hm, do you know how Polylang translates images? Does it create an entirely different image (attachment) that’s translated?

    Thread Starter jpmanson

    (@jpmanson)

    Hi @ryankienstra thank you for your quick reply.

    Polylang doesn’t duplicate the image file, it duplicates the entry in the database so you can translate the caption, name, description, etc. Here’s the documentation from Polylang: https://polylang.pro/doc/working-with-media/

    In the Media Library you see two images: the original one and the translated one, but the image file itself is not duplicated.

    When you want to include an image in a translated page, you only see the images translated for that language (the original image doesn’t appear as an option). So, when I want to select the image for our custom block I only see the translated image (that works fine). But when I see that image in the front the custom block displays the original image and not the translated one.

    While I’m not an experienced programmer, I can try to make changes to the plugin if you send me some pointers. I can also do different tests if that will help, just let me know.

    Thank you again for your time. Kind regards, JP

    Plugin Contributor Ryan Kienstra

    (@ryankienstra)

    @jpmanson,
    Thanks a lot for all of your details.

    Sorry, I don’t think I’ll be able to help on this without learning a lot about the internals about Polylang.

    Thread Starter jpmanson

    (@jpmanson)

    Hello @ryankienstra thank you for your reply.

    Could you point me to documentation so I can understand how Genesis Custom Blocks handles the field type Image please?

    Perhaps I can use that and talk with the Polylang team.

    Kind regards,

    JP

    Plugin Contributor Ryan Kienstra

    (@ryankienstra)

    Hi @jpmanson,
    Sure, block_value( 'work-image' ) gets the attachment (image) ID:

    https://developer.wpengine.com/genesis-custom-blocks/fields/image/

    Thread Starter jpmanson

    (@jpmanson)

    Thank you @ryankienstra !

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Images with translated captions’ is closed to new replies.