{"id":26415,"date":"2023-02-09T04:59:35","date_gmt":"2023-02-09T09:59:35","guid":{"rendered":"https:\/\/plumrocket.com\/docs\/?p=26415"},"modified":"2023-02-09T05:36:43","modified_gmt":"2023-02-09T10:36:43","slug":"how-to-lazy-load-images-within-magento-blocks-or-containers","status":"publish","type":"post","link":"https:\/\/plumrocket.com\/docs\/magento-lazy-load\/v1\/userguides\/blocks","title":{"rendered":"How to Lazy Load Images within Magento Blocks or Containers"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">With <a href=\"\/magento-lazy-load\">Magento 2 Lazy Load<\/a> and <a href=\"\/magento-page-speed-optimizer\">Page Speed Optimizer<\/a> extensions, you can lazy load images within pre-defined blocks that you can choose in the configuration panel. Also, you can specify custom blocks\/containers, and this article will show you how to do this correctly.<\/p>\n\n\n\n<div class=\"wp-block-group pr-notice pr-notice-info\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<p class=\"pr-notice-title wp-block-paragraph\">Step-by-step guide:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>In the main Magento menu, go to the&nbsp;<strong>Plumrocket<\/strong>&nbsp;tab &gt; select&nbsp;<strong>Lazy Load&nbsp;<\/strong>&gt;&nbsp;<strong>Configuration<\/strong><\/li><li>In the <strong>Blocks<\/strong> field under the <strong>Image Lazy Loading<\/strong> tab, list the blocks or containers within which all images should be lazy loaded. The list of supported formats is described in this article below.<\/li><li>Click <strong>Save Config<\/strong>.<\/li><\/ol>\n<\/div><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1206\" height=\"555\" src=\"https:\/\/plumrocket.com\/docs\/wp-content\/uploads\/2023\/02\/magento-2-lazy-load-extension-how-to-blocks-1.png\" alt=\"Magento 2 Lazy Load extension - Lazy Load images within custom blocks or containers\" class=\"wp-image-26421\" srcset=\"https:\/\/plumrocket.com\/docs\/wp-content\/uploads\/2023\/02\/magento-2-lazy-load-extension-how-to-blocks-1.png 1206w, https:\/\/plumrocket.com\/docs\/wp-content\/uploads\/2023\/02\/magento-2-lazy-load-extension-how-to-blocks-1-300x138.png 300w, https:\/\/plumrocket.com\/docs\/wp-content\/uploads\/2023\/02\/magento-2-lazy-load-extension-how-to-blocks-1-1024x471.png 1024w, https:\/\/plumrocket.com\/docs\/wp-content\/uploads\/2023\/02\/magento-2-lazy-load-extension-how-to-blocks-1-768x353.png 768w\" sizes=\"auto, (max-width: 1206px) 100vw, 1206px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-to-specify-custom-containers\">How to Specify Custom Containers<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you want to lazy load images inside the whole section (footer, sidebar, etc.), you can specify the container name. For example,  <code class=\"\" data-line=\"\">footer<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-to-specify-custom-blocks\">How to Specify Custom Blocks<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Custom blocks can be identified by their name, class name, or template.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-block-name\">Block Name<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The advantage of lazy loading images by block name is that it can be applied across different Magento instances, as custom themes usually don&#8217;t change block names. Please note, that block aliases are not yet supported.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To use this method, you need to find the block name in the <a href=\"https:\/\/developer.adobe.com\/commerce\/frontend-core\/guide\/layouts\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Magento layout<\/a>. For example, <code class=\"\" data-line=\"\">category.products.list<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-block-class-name\">Block Class Name<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">By specifying the PHP class name of the block, you will initiate the lazy loading of images within it and all inherited blocks. It is especially useful for widgets as their block names are anonymized. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Format example for the block class name:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code class=\"\" data-line=\"\">Magento\\Catalog\\Block\\Product\\ListProduct<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-block-template\">Block Template<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can use block templates to lazy load images inside them, for example, if blocks don&#8217;t have class names.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Format examples: <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code class=\"\" data-line=\"\">Magento_Catalog::product\/list.phtml<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code class=\"\" data-line=\"\">product\/list.phtml<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>With Magento 2 Lazy Load and Page Speed Optimizer extensions, you can lazy load images within pre-defined blocks that you can choose in the configuration panel. Also, you can specify custom blocks\/containers, and this article will show you how to do this correctly. Step-by-step guide: In the main Magento menu, go to the&nbsp;Plumrocket&nbsp;tab &gt; select&nbsp;Lazy &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/plumrocket.com\/docs\/magento-lazy-load\/v1\/userguides\/blocks\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Lazy Load Images within Magento Blocks or Containers&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[372],"tags":[],"class_list":["post-26415","post","type-post","status-publish","format-standard","hentry","category-magento-lazy-load-v1-userguide","entry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Lazy Load Images within Magento Blocks or Containers - Plumrocket Documentation<\/title>\n<meta name=\"description\" content=\"With Magento 2 Lazy Load and Page Speed Optimizer extensions, you can lazy load images within pre-defined blocks that you can choose in the configuration\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/plumrocket.com\/docs\/magento-lazy-load\/v1\/userguides\/blocks\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Lazy Load Images within Magento Blocks or Containers - Plumrocket Documentation\" \/>\n<meta property=\"og:description\" content=\"With Magento 2 Lazy Load and Page Speed Optimizer extensions, you can lazy load images within pre-defined blocks that you can choose in the configuration\" \/>\n<meta property=\"og:url\" content=\"https:\/\/plumrocket.com\/docs\/magento-lazy-load\/v1\/userguides\/blocks\" \/>\n<meta property=\"og:site_name\" content=\"Plumrocket Documentation\" \/>\n<meta property=\"article:published_time\" content=\"2023-02-09T09:59:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-02-09T10:36:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/plumrocket.com\/docs\/wp-content\/uploads\/2023\/02\/magento-2-lazy-load-extension-how-to-blocks-1.png\" \/>\n<meta name=\"author\" content=\"Plumrocket\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Plumrocket\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Lazy Load Images within Magento Blocks or Containers - Plumrocket Documentation","description":"With Magento 2 Lazy Load and Page Speed Optimizer extensions, you can lazy load images within pre-defined blocks that you can choose in the configuration","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/plumrocket.com\/docs\/magento-lazy-load\/v1\/userguides\/blocks","og_locale":"en_US","og_type":"article","og_title":"How to Lazy Load Images within Magento Blocks or Containers - Plumrocket Documentation","og_description":"With Magento 2 Lazy Load and Page Speed Optimizer extensions, you can lazy load images within pre-defined blocks that you can choose in the configuration","og_url":"https:\/\/plumrocket.com\/docs\/magento-lazy-load\/v1\/userguides\/blocks","og_site_name":"Plumrocket Documentation","article_published_time":"2023-02-09T09:59:35+00:00","article_modified_time":"2023-02-09T10:36:43+00:00","og_image":[{"url":"https:\/\/plumrocket.com\/docs\/wp-content\/uploads\/2023\/02\/magento-2-lazy-load-extension-how-to-blocks-1.png","type":"","width":"","height":""}],"author":"Plumrocket","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Plumrocket","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/plumrocket.com\/docs\/magento-lazy-load\/v1\/userguides\/blocks#article","isPartOf":{"@id":"https:\/\/plumrocket.com\/docs\/magento-lazy-load\/v1\/userguides\/blocks"},"author":{"name":"Plumrocket","@id":"https:\/\/plumrocket.com\/docs\/#\/schema\/person\/c96fccdb89342ae6804272265723eca8"},"headline":"How to Lazy Load Images within Magento Blocks or Containers","datePublished":"2023-02-09T09:59:35+00:00","dateModified":"2023-02-09T10:36:43+00:00","mainEntityOfPage":{"@id":"https:\/\/plumrocket.com\/docs\/magento-lazy-load\/v1\/userguides\/blocks"},"wordCount":282,"image":{"@id":"https:\/\/plumrocket.com\/docs\/magento-lazy-load\/v1\/userguides\/blocks#primaryimage"},"thumbnailUrl":"https:\/\/plumrocket.com\/docs\/wp-content\/uploads\/2023\/02\/magento-2-lazy-load-extension-how-to-blocks-1.png","articleSection":["How-to Guides"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/plumrocket.com\/docs\/magento-lazy-load\/v1\/userguides\/blocks","url":"https:\/\/plumrocket.com\/docs\/magento-lazy-load\/v1\/userguides\/blocks","name":"How to Lazy Load Images within Magento Blocks or Containers - Plumrocket Documentation","isPartOf":{"@id":"https:\/\/plumrocket.com\/docs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/plumrocket.com\/docs\/magento-lazy-load\/v1\/userguides\/blocks#primaryimage"},"image":{"@id":"https:\/\/plumrocket.com\/docs\/magento-lazy-load\/v1\/userguides\/blocks#primaryimage"},"thumbnailUrl":"https:\/\/plumrocket.com\/docs\/wp-content\/uploads\/2023\/02\/magento-2-lazy-load-extension-how-to-blocks-1.png","datePublished":"2023-02-09T09:59:35+00:00","dateModified":"2023-02-09T10:36:43+00:00","author":{"@id":"https:\/\/plumrocket.com\/docs\/#\/schema\/person\/c96fccdb89342ae6804272265723eca8"},"description":"With Magento 2 Lazy Load and Page Speed Optimizer extensions, you can lazy load images within pre-defined blocks that you can choose in the configuration","breadcrumb":{"@id":"https:\/\/plumrocket.com\/docs\/magento-lazy-load\/v1\/userguides\/blocks#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/plumrocket.com\/docs\/magento-lazy-load\/v1\/userguides\/blocks"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/plumrocket.com\/docs\/magento-lazy-load\/v1\/userguides\/blocks#primaryimage","url":"https:\/\/plumrocket.com\/docs\/wp-content\/uploads\/2023\/02\/magento-2-lazy-load-extension-how-to-blocks-1.png","contentUrl":"https:\/\/plumrocket.com\/docs\/wp-content\/uploads\/2023\/02\/magento-2-lazy-load-extension-how-to-blocks-1.png","width":1206,"height":555},{"@type":"BreadcrumbList","@id":"https:\/\/plumrocket.com\/docs\/magento-lazy-load\/v1\/userguides\/blocks#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Magento 2 Extensions","item":"https:\/\/plumrocket.com\/magento-extensions"},{"@type":"ListItem","position":2,"name":"Magento 2 Lazy Load","item":"https:\/\/plumrocket.com\/magento-lazy-load"},{"@type":"ListItem","position":3,"name":"Documentation","item":"https:\/\/plumrocket.com\/docs\/magento-lazy-load"},{"@type":"ListItem","position":4,"name":"v1","item":"https:\/\/plumrocket.com\/docs\/magento-lazy-load\/v1"},{"@type":"ListItem","position":5,"name":"How-to Guides","item":"https:\/\/plumrocket.com\/docs\/magento-lazy-load\/v1\/userguides"},{"@type":"ListItem","position":6,"name":"How to Lazy Load Images within Magento Blocks or Containers"}]},{"@type":"WebSite","@id":"https:\/\/plumrocket.com\/docs\/#website","url":"https:\/\/plumrocket.com\/docs\/","name":"Plumrocket Documentation","description":"Extensions docs, troubleshootings etc.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/plumrocket.com\/docs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/plumrocket.com\/docs\/#\/schema\/person\/c96fccdb89342ae6804272265723eca8","name":"Plumrocket","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/30d7e8cb4567485b56880a1658849a1252ac12806e8f95b3be71e986bf5eabee?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/30d7e8cb4567485b56880a1658849a1252ac12806e8f95b3be71e986bf5eabee?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/30d7e8cb4567485b56880a1658849a1252ac12806e8f95b3be71e986bf5eabee?s=96&d=mm&r=g","caption":"Plumrocket"}}]}},"_links":{"self":[{"href":"https:\/\/plumrocket.com\/docs\/wp-json\/wp\/v2\/posts\/26415","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/plumrocket.com\/docs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/plumrocket.com\/docs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/plumrocket.com\/docs\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/plumrocket.com\/docs\/wp-json\/wp\/v2\/comments?post=26415"}],"version-history":[{"count":10,"href":"https:\/\/plumrocket.com\/docs\/wp-json\/wp\/v2\/posts\/26415\/revisions"}],"predecessor-version":[{"id":26432,"href":"https:\/\/plumrocket.com\/docs\/wp-json\/wp\/v2\/posts\/26415\/revisions\/26432"}],"wp:attachment":[{"href":"https:\/\/plumrocket.com\/docs\/wp-json\/wp\/v2\/media?parent=26415"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/plumrocket.com\/docs\/wp-json\/wp\/v2\/categories?post=26415"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/plumrocket.com\/docs\/wp-json\/wp\/v2\/tags?post=26415"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}