Css Tricks<\/a>.<\/p>\n\n function content_filter( $content ) {\n\t$matches = array();\n\tpreg_match_all( '\/
\/', $content, $matches );\n\n\t$search = array();\n\t$replace = array();\n\n foreach ( $matches[0] as $image ) {\n\n\t$replace = preg_replace( '\/<img(.*?)src=\/i',\n'<img$1src="data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"\ndata-original=', $image );\n\nif ( preg_match( '\/class=["\\']\/i', $replace ) ) {\n$replace = preg_replace( '\/class=(["\\'])(.*?)["\\']\/i', 'class=$1lazy $2$1', $replace );\n} else {\n$replace = preg_replace( '\/<img\/i', '<img class="lazy"', $replace );\n \t\t}\n\n$replace .= '' . $image . '';\n\narray_push( $search, $image );\narray_push( $replace, $replace );\n\n }\n\n$content = str_replace( $search, $replace, $content );\n\nreturn $content;\n\n }\n<\/pre>\n4.<\/h3>\n
Jako posledn\u00ed vytvo\u0159\u00edme funkci pro vypr\u00e1zdn\u011bn\u00ed bufferu a um\u00edst\u00edme ji do wp_head.<\/p>\n
\nadd_action('wp_footer', 'buffer_end');\nfunction buffer_end() {\n $content = ob_get_clean();\n echo content_filter($content);\n}\n<\/pre>\nA to je v\u0161e.
\nT\u011b\u0161\u00edm se u dal\u0161\u00edho \u010dl\u00e1nku.<\/p>\n","protected":false},"excerpt":{"rendered":"
Lazy load je postup, p\u0159i kter\u00e9m na\u010d\u00edt\u00e1 va\u0161e webov\u00e1 str\u00e1nka obr\u00e1zky a\u017e pot\u00e9, co se maj\u00ed zobrazit. V\u00fdhodn\u00e9 je to p\u0159i del\u0161\u00ed str\u00e1nce, kdy\u017e se m\u00e1 na\u010d\u00edst t\u0159eba \u010dty\u0159icet obr\u00e1zk\u016f. Str\u00e1nka se pak na\u010d\u00edt\u00e1 ne\u00fam\u011brn\u011b dlouho a u\u017eivatel m\u016f\u017ee odej\u00edt. V tomto \u010dl\u00e1nku si uk\u00e1\u017eeme, jak Lazy load jednodu\u0161e pou\u017e\u00edt ve va\u0161\u00ed \u0161ablon\u011b. Co budeme<\/p>\n","protected":false},"author":1,"featured_media":1484,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[12,30],"tags":[499],"class_list":["post-1836","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-navody","category-wordpress","tag-wordpress-lazy-load"],"uagb_featured_image_src":{"full":["https:\/\/affinite.io\/cs\/wp-content\/uploads\/sites\/2\/2014\/01\/3.png",620,620,false],"thumbnail":["https:\/\/affinite.io\/cs\/wp-content\/uploads\/sites\/2\/2014\/01\/3-150x150.png",150,150,true],"medium":["https:\/\/affinite.io\/cs\/wp-content\/uploads\/sites\/2\/2014\/01\/3-300x300.png",300,300,true],"medium_large":["https:\/\/affinite.io\/cs\/wp-content\/uploads\/sites\/2\/2014\/01\/3.png",620,620,false],"large":["https:\/\/affinite.io\/cs\/wp-content\/uploads\/sites\/2\/2014\/01\/3.png",620,620,false],"1536x1536":["https:\/\/affinite.io\/cs\/wp-content\/uploads\/sites\/2\/2014\/01\/3.png",620,620,false],"2048x2048":["https:\/\/affinite.io\/cs\/wp-content\/uploads\/sites\/2\/2014\/01\/3.png",620,620,false],"archive-list":["https:\/\/affinite.io\/cs\/wp-content\/uploads\/sites\/2\/2014\/01\/3-400x265.png",400,265,true]},"uagb_author_info":{"display_name":"Affinite","author_link":"https:\/\/affinite.io\/cs\/author\/affinite\/"},"uagb_comment_info":0,"uagb_excerpt":"Lazy load je postup, p\u0159i kter\u00e9m na\u010d\u00edt\u00e1 va\u0161e webov\u00e1 str\u00e1nka obr\u00e1zky a\u017e pot\u00e9, co se maj\u00ed zobrazit. V\u00fdhodn\u00e9 je to p\u0159i del\u0161\u00ed str\u00e1nce, kdy\u017e se m\u00e1 na\u010d\u00edst t\u0159eba \u010dty\u0159icet obr\u00e1zk\u016f. Str\u00e1nka se pak na\u010d\u00edt\u00e1 ne\u00fam\u011brn\u011b dlouho a u\u017eivatel m\u016f\u017ee odej\u00edt. V tomto \u010dl\u00e1nku si uk\u00e1\u017eeme, jak Lazy load jednodu\u0161e pou\u017e\u00edt ve va\u0161\u00ed \u0161ablon\u011b. Co budeme","_links":{"self":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/1836"}],"collection":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/comments?post=1836"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/1836\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media\/1484"}],"wp:attachment":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media?parent=1836"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=1836"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=1836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}