{"id":2062,"date":"2014-10-10T15:58:36","date_gmt":"2014-10-10T15:58:36","guid":{"rendered":"http:\/\/musilda.cz\/?p=2062"},"modified":"2014-10-10T15:58:36","modified_gmt":"2014-10-10T15:58:36","slug":"odstraneni-rozmeru-obrazku-v-kodu-prispevku","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/odstraneni-rozmeru-obrazku-v-kodu-prispevku\/","title":{"rendered":"Odstran\u011bn\u00ed rozm\u011br\u016f obr\u00e1zku v k\u00f3du p\u0159\u00edsp\u011bvku"},"content":{"rendered":"
Zn\u00e1te to, m\u00e1te responsivn\u00ed \u0161ablonu a p\u0159id\u00e1te do p\u0159\u00edsp\u011bvku obr\u00e1zek. A najednou se div\u00edte, \u017ee na tabletu p\u0159et\u00e9k\u00e1 z obsahu ven a rozbije v\u00e1m layout. Probl\u00e9mem m\u016f\u017ee b\u00fdt to, \u017ee WordPress k vlo\u017een\u00e9mu obr\u00e1zku p\u0159id\u00e1v\u00e1 i jeho rozm\u011bry v pixelech.<\/p>\n
A\u0165 ji\u017e z tohoto d\u016fvodu, nebo jin\u00e9ho, m\u016f\u017eete cht\u00edt rozm\u011bry z tagu img odstranit.<\/p>\n
Tento jednoduch\u00fd snippet d\u011bl\u00e1 p\u0159esn\u011b to co pot\u0159ebujete<\/p>\n
\nadd_filter( 'post_thumbnail_html', 'remove_image_attribute', 10 );\nadd_filter( 'image_send_to_editor', 'remove_image_attribute', 10 );\n\nfunction remove_image_attribute( $html ) {\n $html = preg_replace( '\/(width|height)=\\\"\\d*\\\"\\s\/', \"\", $html );\n return $html;\n}\n<\/pre>\nPrvn\u00ed filtr odstran\u00ed rozm\u011bry z n\u00e1hledov\u00fdch obr\u00e1zk\u016f, druh\u00fd je odebere p\u0159i vkl\u00e1d\u00e1n\u00ed obr\u00e1zku v editoru.
\nK\u00f3d vlo\u017ete do functions.php<\/p>\n","protected":false},"excerpt":{"rendered":"
Zn\u00e1te to, m\u00e1te responsivn\u00ed \u0161ablonu a p\u0159id\u00e1te do p\u0159\u00edsp\u011bvku obr\u00e1zek. A najednou se div\u00edte, \u017ee na tabletu p\u0159et\u00e9k\u00e1 z obsahu ven a rozbije v\u00e1m layout. Probl\u00e9mem m\u016f\u017ee b\u00fdt to, \u017ee WordPress k vlo\u017een\u00e9mu obr\u00e1zku p\u0159id\u00e1v\u00e1 i jeho rozm\u011bry v pixelech. A\u0165 ji\u017e z tohoto d\u016fvodu, nebo jin\u00e9ho, m\u016f\u017eete cht\u00edt rozm\u011bry z tagu img odstranit. Tento<\/p>\n","protected":false},"author":1,"featured_media":1978,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[19],"tags":[],"class_list":["post-2062","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-snippety"],"_links":{"self":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/2062"}],"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=2062"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/2062\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media\/1978"}],"wp:attachment":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media?parent=2062"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=2062"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=2062"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}