Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Patrick Sletvold

    (@16patsle)

    Hi @maan18!

    I’m afraid I might need a bit more details to be able to help you. What’s the issue you are encountering? Is there a problem with your theme, or are you for example using the picture element tag, which doesn’t yet have full support (though it’s coming very soon)? Does the problem occur in several different browsers or just one? Where did you try adding get_lazysizes_html? As soon as I hear back from you, I’ll try to find a solution.

    – Patrick Sletvold

    Thread Starter designweb

    (@maan18)

    there is no problem in theme. it’s work perfectly fine on get_the_post_thumbnail. you can check my code here.
    https://pastebin.com/T2wmpFUu

    Plugin Author Patrick Sletvold

    (@16patsle)

    Hi!

    I’ve looked at your code, and I believe I have found the issue. get_lazysizes_html does not operate directly on the image src, but rather on a complete HTML string, containing an entire img tag. Taking this into account, the last part of your code might look something like this:

    
    get_lazysizes_html(
    	'<img
    	class="featured-thumb' . ($animated_gif) ? ' featured-thumb-gif-class' : '' . '"
    	data-animated-gif-src-medium="' . $imgsrc[0] . '"
    	data-animated-gif-src-full="' . $animated_gif_imgsrc_full[0] . '"
    	src="' . $imgsrc[0] . '"
    	alt="' . mb_strimwidth(the_title_attribute('echo=0'), 0, 100, ' ...') . '"
    	style="width:' . $imgsrc[1] . 'px;height:' . $imgsrc[2] . 'px" />'
    );
    

    (quick untested sketch, note that I had to convert the html to php strings)

    Hopefully this will help you solve the problem. Let me know if you have any more questions.

    – Patrick Sletvold

    Thread Starter designweb

    (@maan18)

    Thanks for your effort.
    i tested it out but images are not shown.

    Plugin Author Patrick Sletvold

    (@16patsle)

    If you copied it directly, it’s most likely because I missed using echo.

    
    echo get_lazysizes_html(
    	'<img
    	class="featured-thumb' . ($animated_gif) ? ' featured-thumb-gif-class' : '' . '"
    	data-animated-gif-src-medium="' . $imgsrc[0] . '"
    	data-animated-gif-src-full="' . $animated_gif_imgsrc_full[0] . '"
    	src="' . $imgsrc[0] . '"
    	alt="' . mb_strimwidth(the_title_attribute('echo=0'), 0, 100, ' ...') . '"
    	style="width:' . $imgsrc[1] . 'px;height:' . $imgsrc[2] . 'px" />'
    );
    
    Thread Starter designweb

    (@maan18)

    the image tag is missing you can check the screenshot here.

    image error

    Plugin Author Patrick Sletvold

    (@16patsle)

    I noticed my PHP code from earlier was a bit off. Should be more correct now:

    
    echo get_lazysizes_html(
    	'<img
    	class="featured-thumb' . (($animated_gif) ? ' featured-thumb-gif-class" data-animated-gif-src-medium="' . $imgsrc[0] . '" data-animated-gif-src-full="' . $animated_gif_imgsrc_full[0] : '') . '"
    	src="' . $imgsrc[0] . '"
    	alt="' . mb_strimwidth(the_title_attribute('echo=0'), 0, 100, ' ...') . '"
    	style="width:' . $imgsrc[1] . 'px;height:' . $imgsrc[2] . 'px" />'
    );
    

    I haven’t looked into whether or not that was the problem, but it it still doesn’t work I can look further into it a bit later.

    Thread Starter designweb

    (@maan18)

    Thanks!, it worked

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Not working’ is closed to new replies.