• Hey,

    I have a weird issue, when I activate the plugin, my img url are correctly replaced when it’s an image tag : .

    But when I have a div with inline style, the uris are not replaced.

    For example, if I execute the following code, just img will be replaced, not the inline style :

    <section>
        <div>
          @php $bgImage = "background-image:url(". $slider_home[0]->url .")" @endphp
          <img src="{{ $slider_home[0]->url }}"/>
          <div
            style="{!! $bgImage !!}"
          >
          </div>
        </div>
      </section>

    Do you have any explanations ?
    I have to admit I don’t understand why …

    To be sure, I deactivated my cache plugin (wp fatest cache), but anyway, style have the problem.

    Thanks,

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Gerard Blanco

    (@sixaxis)

    Hi @jlgouwy,

    Can you tell me where I can see the issue live, please?

    Thank you,

    Thread Starter jlgouwy

    (@jlgouwy)

    Hi @sixaxis

    I didn’t activate it in live, because it didn’t work.
    I have a freemium plan, I didn’t want to consume all free images.
    What do you need as complementary informations ?

    Plugin Support Gerard Blanco

    (@sixaxis)

    Hi @jlgouwy,

    If we can’t see your site it will be kind of difficult to troubleshoot this, but let’s give it a try.

    Can you please send me screenshots of:

    • what you see on your website
    • what the source code looks like exactly for the problematic image
    • your ShortPixel settings

    Thanks!

    Thread Starter jlgouwy

    (@jlgouwy)

    @sixaxis ,

    what you see on your website
    => It replaces correctly the domain by when it’s a simply img tag by :
    https://cdn.shortpixel.ai/spai/&#8230;.
    => When it’s a div tag with style inline with background-image, it doesn’t replace it.

    what the source code looks like exactly for the problematic image
    => I already give in my presentation. It was a simple test code.
    it does not work for inline style. But works for image tag.

    your ShortPixel settings
    => In settings “area”:
    i enabled Serve the SVG images through the ShortPixel CDN
    i enabled Replace background images in the CSS cached by WP Fastest Cache.
    i enabled Also parse JSON AJAX calls to replace image URLs.
    i enabled Lazy-load the background images from inline STYLE blocks.

    Cheers,

    Plugin Support Gerard Blanco

    (@sixaxis)

    Thank you @jlgouwy.

    Allow me to insist in having more details about this. Even a single space in the code is relevant ??

    1) Could you please copy-paste here the source code as the browser sees it? Including image URLs; no PHP code.

    2) Could you please send us actual screenshots from your ShortPixel settings?

    Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Img src is replaced but not background-img’ is closed to new replies.