Not working
-
hi,
i add the markup “get_lazysizes_html” but it still not working any fix.
-
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
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/T2wmpFUuHi!
I’ve looked at your code, and I believe I have found the issue.
get_lazysizes_htmldoes 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
Thanks for your effort.
i tested it out but images are not shown.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" />' );the image tag is missing you can check the screenshot here.
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.
Thanks!, it worked
The topic ‘Not working’ is closed to new replies.