This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
*

siken

  • ****
  • 138 posts
Lazy for image.png
« on: April 09, 2020, 04:15:34 PM »
In the loop-single.php image there is a src="<?php echo (bet_is_lazy() ? bet_get_noimage() : osc_resource_thumbnail_url()); ?>"

If I want to use an image with lazy loading of images for a /image.png what is the link I should put there?

I tried src="/image.png" but it doesn't work

*

MB Themes

Re: Lazy for image.png
« Reply #1 on: April 10, 2020, 01:33:30 PM »
@alexandrompt
Simply look on function bet_get_noimage(), should be no-image.png in theme's image folder
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

siken

  • ****
  • 138 posts
Re: Lazy for image.png
« Reply #2 on: April 10, 2020, 05:22:58 PM »
In loop-single.php images are loaded only when displayed on screen, thanks to Lazy.

The case is that in footer I have a carousel of images and I want them to be loaded only when the user reaches the carousel.

In loop-single.php is the following link:

Code: [Select]
<a class="img" href="<?php echo osc_item_url(); ?>"><img class="<?php echo (bet_is_lazy() ? 'lazy' ''); ?>" src="<?php echo (bet_is_lazy() ? bet_get_noimage() : osc_resource_thumbnail_url()); ?>" data-src="<?php echo osc_resource_thumbnail_url(); ?>" alt="<?php echo osc_esc_html(osc_item_title()); ?>" /></a>
How do I have to put the link so that an image for example /image.png loads only when it appears on the screen?


ยป This does not work:

Code: [Select]
<a class="img" href="/image.png"><img class="<?php echo (bet_is_lazy() ? 'lazy' ''); ?>" src="<?php echo (bet_is_lazy() ? bet_get_noimage() : osc_resource_thumbnail_url()); ?>" data-src="/image.png" alt="image" /></a>

*

MB Themes

Re: Lazy for image.png
« Reply #3 on: April 10, 2020, 08:16:03 PM »
No idea what you mean
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

siken

  • ****
  • 138 posts
Re: Lazy for image.png
« Reply #4 on: April 10, 2020, 09:58:54 PM »
In head.php you have the code
Code: [Select]
osc_register_script('lazyload', 'https://cdnjs.cloudflare.com/ajax/libs/jquery.lazy/1.7.9/jquery.lazy.min.js'); to use the Lazy utility and show photos only when you swipe the screen.

In loop-single.php you have the code
Code: [Select]
<a class="img" href="<?php echo osc_item_url(); ?>"><img class="<?php echo (bet_is_lazy() ? 'lazy' ''); ?>" src="<?php echo (bet_is_lazy() ? bet_get_noimage() : osc_resource_thumbnail_url()); ?>" data-src="<?php echo osc_resource_thumbnail_url(); ?>" alt="<?php echo osc_esc_html(osc_item_title()); ?>" /></a>
I want to use that code but for another image, for example image.png

What is the code to use Lazy with image.png?

*

MB Themes

Re: Lazy for image.png
« Reply #5 on: April 10, 2020, 10:19:47 PM »
@alexandrompt
Simply look on function bet_get_noimage(), should be no-image.png in theme's image folder
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

siken

  • ****
  • 138 posts
Re: Lazy for image.png
« Reply #6 on: April 10, 2020, 10:22:24 PM »
Can you put the code ?, because I don't understand you

*

MB Themes

Re: Lazy for image.png
« Reply #7 on: April 11, 2020, 11:00:22 PM »
That function is in functions.php
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Marked as best answer by leales_org on April 12, 2020, 03:16:44 PM
*

siken

  • ****
  • 138 posts
Re: Lazy for image.png
« Reply #8 on: April 12, 2020, 03:16:36 PM »
don't bother, I've already found out:

Code: [Select]
<img loading="lazy" class="<?php echo (bet_is_lazy() ? 'lazy' ''); ?>" src="<?php echo (bet_is_lazy() ? bet_get_noimage() : '/imageexample.jpg'); ?>" data-src="/imageexample.jpg" alt="imageexamplename">
This is important for the images that we have in the footer, since they will not load until they are shown on the screen.

That way, the web loads much faster, because it loads the images / no-image.png image until the user downloads the scroll to the footer.
« Last Edit: April 14, 2020, 11:00:41 PM by alexandromt »

*

MB Themes

Re: Lazy for image.png
« Reply #9 on: April 16, 2020, 12:17:54 PM »
@alexandromt
I do not see any point of that as lazyload handles that all.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots