• Resolved MisterR

    (@mister_r)


    Hi rosell.dk,

    We’ve started using your plugin recently and now have a question.

    Is there a way to use functions from your plugin files to get WebP images for custom fields created by Advanced Custom Fields plugin.

    Let assume we have the following situation.

    We have custom fields created by ACF for a particular page template.

    In PHP file of this page template we get image URL (or array with all image attributes) via get_field() function

    $image = get_field('banner_image');

    Then we output this image

    printf("<img src='%s' alt='%s' />", $image['url'], $image['alt'])

    What actions do we have to do to get

    <picture>
      <source>
      <img>

    instead of plain image tag?

    • This topic was modified 5 years, 2 months ago by MisterR.
    • This topic was modified 5 years, 2 months ago by MisterR.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter MisterR

    (@mister_r)

    Any updates?

    Plugin Author rosell.dk

    (@roselldk)

    Hi MisterR,

    I have not build any functions with this in mind.
    If you are using “Alter HTML”, you can simply output plain img tags and let WebP Express alter the HTML. On the other hand, in “Varied image responses” mode, there is no real need either to use picture tag syntax.

    So I don’t see a need for such function.

    • This reply was modified 5 years, 1 month ago by rosell.dk.
    Plugin Author rosell.dk

    (@roselldk)

    That said, there are some minor benefits of outputting a picture tag syntax when you are in varied image responses and decided against using Alter HTML. For example, if user right-clicks the image and saves it to disk, there will not be a mismatch between extension and file type with the picture tag.

    I assumed you are editing a page template for a single site?
    In that case you should have exact knowledge of where the webp is outputted (depends on the WebP Express settings). Simply use that knowledge to create your picture tag.

    • This reply was modified 5 years, 1 month ago by rosell.dk.
    Thread Starter MisterR

    (@mister_r)

    OK. Thank you. It was helpful.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WebP Express + ACF’ is closed to new replies.