• I have a gallery that is loading a lot of images, and have added a lazy load plugin (s3 lazy load), however I needed to add the width and height of the images to make the gallery compatible. The lazy load support option within the plugin, fixes the compatibility but stopped the lazy loading functionality.

    Would it be possible to add the height and width of the attachment images to the img element to make this plugin fully lazy load compatible for future releases?

    Here is the change I made to the MasonryGallery.php file to include the width and height of the attachment:

     $image_attributes = wp_get_attachment_image_src( $attachment_id, "full"  );
    
                $items[] = sprintf(
                    '<div class="grid-item et_pb_gallery_image">
                        <a href="%1$s"%4$s%5$s>
                            <img width="%10$s"
                            	height="%11$s"
                            	src="%1$s"
                                 alt="%2$s"
                                 title="%3$s"
                                 srcset="%9$s 768w, %8$s 980w, %7$s 1024w"
                                 sizes="(max-width: 768px) 768px, (max-width: 980px) 980px, 1024px" />
                            %6$s
                        </a>
                    </div>',
                    $image,
                    $image_alt,
                    $image_title,
                    'on' === $args["title_in_lightbox"] ?  " data-title='$image_title'" : '',
                    'on' === $args["caption_in_lightbox"] ?  " data-caption='" . wp_get_attachment_caption($attachment_id) . "'" : '',
                    'on' === $args['use_overlay'] ? et_core_esc_previously($overlay_output) : "",
                    $image_desktop_url,
                    $image_tablet_url,
                    $image_phone_url,
                    $image_attributes[1],
                    $image_attributes[2]
                );
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘lazy load support’ is closed to new replies.