• Resolved Nazrinn

    (@nazrinn)


    I am loading some images through PHP (custom post type with Advanced Custom Fields) and Optimole’s srcset doesn’t seem to be applied automatically to those images.

    Is there a way to fetch an image’s Optimole srcset in PHP as a string?

    That would really help me out.

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Poonam Namdev

    (@poonam9)

    Hi @nazrinn,

    Thank you for using Optimole.

    Can you please share the page URL where we can see the structure of the images that you are adding using PHP?

    Thread Starter Nazrinn

    (@nazrinn)

    Of course!

    You can see the HTML without the srcset on the first picture in the slider.
    https://staging.barbandcarole.ca/listings/the-green-enclave-14-ballyhaise-street/

    As a sneak-peak, the image’s HTML looks like this:
    <img data-lazyloaded="1" src="https://ml275xldtxd5.i.optimole.com/UkHvqLs.NsTa~26973/w:auto/h:auto/q:82/id:abd37e3b689d3d97a8024abb8f9192e8/https://barbandcarole.ca/DJI_0816.jpg" decoding="async" id="slider-picture-generalities-1" data-property-section="generalities" data-src="https://ml275xldtxd5.i.optimole.com/UkHvqLs.NsTa~26973/w:auto/h:auto/q:82/id:abd37e3b689d3d97a8024abb8f9192e8/https://barbandcarole.ca/DJI_0816.jpg" width="1170" class="litespeed-loaded" data-was-processed="true">

    And the PHP that generated the HTML:
    '<img id="slider-picture-'.$id_html.'-'.$picture_id.'" data-property-section="'.$id_html.'" src="'.$picture['url'].'" width="1170">';

    (This was echoed later.)

    • This reply was modified 3 years, 9 months ago by Nazrinn.
    • This reply was modified 3 years, 9 months ago by Nazrinn.
    Plugin Support Vytis

    (@bvytis)

    Hi @nazrinn,

    We do not add srcset to images, if it is already present we will optimize the URL from the existing srcset.

    Thread Starter Nazrinn

    (@nazrinn)

    That’s interesting.

    I don’t remember adding it on other images I called.
    I guess the srcset is made by WordPress as per the docs. I have never noticed. Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Fetch Optimole’s image srcset when fetching a site image in PHP’ is closed to new replies.