• Resolved omirandab

    (@omirandab)


    Hi, I’m having issues with lazy load, is converting quotes from additional image attributes to html entities, like this:

    <img width="150" height="100" src="https://local.com/app/uploads/140520-150x150.jpg" class="w-full h-full object-cover" alt="Owen Pallett In Conflict" decoding="async" srcset="https://local.com/app/uploads/140520-150x100.jpg 150w, https://local.com/app/uploads/140520-300x199.jpg 300w, https://local.com/app/uploads/140520-620x413.jpg 620w, https://local.com/app/uploads/140520-218x145.jpg 218w, https://local.com/app/uploads/140520-640x426.jpg 640w, https://local.com/app/uploads/140520-320x213.jpg 320w, https://local.com/app/uploads/140520-298x198.jpg 298w, https://local.com/app/uploads/140520-313x209.jpg 313w, https://local.com/app/uploads/140520-191x127.jpg 191w, https://local.com/app/uploads/140520-158x105.jpg 158w, https://local.com/app/uploads/140520-414x276.jpg 414w, https://local.com/app/uploads/140520.jpg 940w" sizes="(max-width: 150px) 100vw, 150px" onerror="this.onerror=null; this.src='https://local.com/app/themes/a-theme/public/images/svg/logo.svg'; this.srcset='https://local.com/app/themes/a-theme/public/images/svg/logo.svg'; this.className='h-9 mx-auto top-[calc(50%-16px)] relative opacity-10';" />

    I have been trying to figure out a way to prevent this, but the only way I figure it out that works is by adding html_entity_decode on the file

    plugins/powered-cache/includes/classes/LazyLoad.php

    At lines 335 and 336

    array_push( $search, html_entity_decode( $img_html ) );
    array_push( $replace, html_entity_decode( $replace_html ) )

    Is there a better workaround for this issue?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mustafa Uysal

    (@m_uysl)

    Hi @omirandab,

    Hi, I’m having issues with lazy load, is converting quotes from additional image attributes to html entities, like this:

    It doesn’t look like converting to HTML entities https://share.cleanshot.com/ScqsKfGv . or I’m missing something? (If you have enabled HTML minification, could you turn it off and see if there is a change?)

    You can give it a try to powered_cache_lazy_load_filter for that,

    add_filter( 'powered_cache_lazy_load_filter', function ( $content ) {
    	return html_entity_decode( $content );
    },999 );

    I hope this helps, let me know if it doesn’t do the trick.

    Thread Starter omirandab

    (@omirandab)

    Thanks for answering so quickly.
    I forgot to add this information, the html entities appear in the <noscript> tag, sorry for missing that.

    We do not have HTML minification enabled.
    The filter did work, but now I’m getting this console error:

    Uncaught SyntaxError: Invalid left-hand side in assignment (at ?s=metalica:1075:2163)

    I can’t make sense of it as its pointing the src of the image inside the noscript tag, which doesn’t happen when I modify the plugin lines directly.

    Plugin Author Mustafa Uysal

    (@m_uysl)

    Hi @omirandab,

    I don’t see a problem with the noscript tags either. They basically move the existing img tags into noscripts when the browser doesn’t support JS. If you have another image-related plugin in place, it might be worth temporarily disabling it or disabling the lazy-load feature in Powered Cache to see if the problem persists.

    Additionally, to provide you with more targeted assistance, could you please share a publicly accessible URL of the page where you’re experiencing this issue? Having direct access to the page will allow me to better diagnose and understand the problem.

    Thread Starter omirandab

    (@omirandab)

    Hello, I appreciate the help.
    You can check the issue on this URL: https://stg.spin.com/?s=metalica

    Plugin Author Mustafa Uysal

    (@m_uysl)

    Hi @omirandab,

    I understand the problem now. Your website’s images are configured with an “onerror” attribute, which is set up to switch to a fallback URL if the original image fails to load.

    The complication arises when lazy-loading is activated because it adds a placeholder image that successfully loads, thus never triggering the “onerror” switch. However, our current lazy-load system lacks support for the “onerror” attribute. As a result, when it attempts to load the actual image, it appears broken due to this missing functionality.

    I’ve opened an issue about this ,but it’s always more preferable to ensure the images are displayed correctly without any errors.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Lazy load is converting quotes from image attributes into HTML entities’ is closed to new replies.