• Resolved dbriard

    (@dbriard)


    Hi,

    I am trying to translate all my images from english to french in a loop (I inpired myself with your translate_media function).

    That works almost ok but on the media admin page (in the list view):
    – the original file look great -> with a tick symbol below the english flag, and a pencil below the french flag.
    – the translated file have to tick symbols.. and so they are not linked correctly.

    I think this is because your translate media function create a new attachment, but without clearing the post fields (see the code below)

    // create a new attachment (translate attachment parent if exists)
    					$post->ID = null; // will force the creation

    I would like to clear the english information from the newly created item, however I have no idea how to do that?

    Could you help please?

    Best Regards,

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

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

    (@chouby)

    Hi!

    I don’t know how you modified the code, but I guess that you did not set the language, while Polylang applies a default one in a ‘save_post’ action, this default language not being consistent with the set of translations you apply. Have a look at pll_set_post_language to apply the language after calling ‘wp_insert_attachment’

    Thread Starter dbriard

    (@dbriard)

    Awesome!

    The two tick icons made me think that both langages was set, but in fact none was set 🙂

    That work perfectly now, thank you!

    I will keep improving by translating the taxonomy with the image at the same time.

    Thank a lot!

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

The topic ‘Problem translating media in a loop’ is closed to new replies.