{"id":18392678,"date":"2025-03-31T21:33:20","date_gmt":"2025-03-31T21:33:20","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/image-preloader\/"},"modified":"2025-03-31T21:33:20","modified_gmt":"2025-03-31T21:33:20","slug":"image-preloader","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/image-preloader\/","title":{"rendered":"image preloader"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hi, I&#8217;m using your plugin a lot and it works fine, thank you. I&#8217;ve got a problem with an image preloader snippet i wrote&#8230; if i mention the attribut <strong>as=image<\/strong> the code break and if i don&#8217;t mention it the dev-tool say it needs a <strong>as<\/strong> attribut&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here&#8217;s my code:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">function humveg_imgs_preloader() {<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">if( ! is_front_page() ) return;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$link = &#8221;;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">foreach( array(&#8216;2024\/03\/bg-mocktails-min.webp&#8217; , &#8216;2024\/03\/bg-smoothie-milkshake-min.webp&#8217; , &#8216;2024\/03\/bg-detox-water-min.webp&#8217;) as $src) {<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$link.='&lt;link rel=\"preload\" fetchpriority=\"high\" as=\"image\" href=\"\/wp-content\/uploads\/'. $src .'\" type=\"image\/webp\"&gt;' . \"\\n\";<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">}<br \/>echo $link;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">}<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">add_action( &#8216;wp_head&#8217;, &#8216;humveg_imgs_preloader&#8217; );<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">without the <strong>as<\/strong> attribut it is print in the head section but with it even don&#8217;t print and break the code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Maybe you have already had this question or knows an issue for me.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thanks a lot<\/p>\n","protected":false},"template":"","class_list":["post-18392678","topic","type-topic","status-publish","hentry","topic-tag-as","topic-tag-image","topic-tag-link","topic-tag-preload","topic-tag-wp_head"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/18392678","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/18392678\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=18392678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}