{"id":3425,"date":"2016-11-17T10:52:52","date_gmt":"2016-11-17T10:52:52","guid":{"rendered":"http:\/\/musilda.cz\/?p=3425"},"modified":"2016-11-17T10:52:52","modified_gmt":"2016-11-17T10:52:52","slug":"ziskat-url-velkeho-obrazku-pomoci-id-nahledoveho-obrazku","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/ziskat-url-velkeho-obrazku-pomoci-id-nahledoveho-obrazku\/","title":{"rendered":"Jak z\u00edskat url velk\u00e9ho obr\u00e1zku pomoc\u00ed id n\u00e1hledov\u00e9ho obr\u00e1zku"},"content":{"rendered":"
Mus\u00edm \u0159\u00edci, \u017ee titulek pro tento snippet se mi moc nepovedl. Ale vystihuje p\u0159esn\u011b to, co m\u00e1 k\u00f3d d\u011blat.<\/p>\n
P\u0159\u00edklad<\/strong>:<\/p>\n pot\u0159ebujete m\u00edt mo\u017enost, otev\u0159\u00edt n\u00e1hledov\u00fd obr\u00e1zek, v popup okn\u011b. M\u016f\u017eete pou\u017e\u00edt jak\u00fdkoliv script, a\u0165 ji\u017e to je Lightbox, Fancybox, nebo n\u011bco jin\u00e9ho.<\/p>\n K tomu ale pot\u0159ebujete m\u00edt url obr\u00e1zku, kter\u00fd chcete v popup okn\u011b otev\u0159\u00edt.<\/p>\n M\u016f\u017eete pou\u017e\u00edt funkci\u00a0wp_get_attachment_image_src(). Aby jste dostali url obr\u00e1zku, je nutn\u00e9 z\u00edskat jeho \u00a0ID.<\/p>\n Tu dostaneme pomoc\u00ed\u00a0get_post_thumbnail_id();<\/p>\n K\u00f3d pak m\u016f\u017ee vypadat takto:<\/p>\n Url obr\u00e1zku, jen\u017e jsme z\u00edskali, je ve velikosti large, kter\u00e1 by pro popup m\u011bla b\u00fdt dostate\u010dn\u00e1. HTML k\u00f3d je z\u00e1visl\u00fd od pou\u017eit\u00e9ho scriptu – pro ilustraci jsem ho vlo\u017eil do data-img.<\/p>\n Nezapome\u0148te, \u017ee dostanete pole, kde url je na prvn\u00ed pozici, tak\u017ee mus\u00edte vypisovat \u00a0$image_url[0].<\/p>\n Zkr\u00e1cen\u011b m\u016f\u017eete pou\u017e\u00edt:<\/p>\n Mus\u00edm \u0159\u00edci, \u017ee titulek pro tento snippet se mi moc nepovedl. Ale vystihuje p\u0159esn\u011b to, co m\u00e1 k\u00f3d d\u011blat. P\u0159\u00edklad: pot\u0159ebujete m\u00edt mo\u017enost, otev\u0159\u00edt n\u00e1hledov\u00fd obr\u00e1zek, v popup okn\u011b. M\u016f\u017eete pou\u017e\u00edt jak\u00fdkoliv script, a\u0165 ji\u017e to je Lightbox, Fancybox, nebo n\u011bco jin\u00e9ho. K tomu ale pot\u0159ebujete m\u00edt url obr\u00e1zku, kter\u00fd chcete v popup okn\u011b otev\u0159\u00edt.<\/p>\n","protected":false},"author":1,"featured_media":2635,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39,19],"tags":[77,382],"class_list":["post-3425","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-attachments","category-snippety","tag-attachment-url","tag-thumbnail"],"_links":{"self":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/3425"}],"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=3425"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/3425\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media\/2635"}],"wp:attachment":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media?parent=3425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=3425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=3425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}$thumbnail_id\u00a0=\u00a0get_post_thumbnail_id(\u00a0$post_id\u00a0);\n\n$image_url =\u00a0wp_get_attachment_image_src( $thumbnail_id, 'large' );\n\n<img src=\"<?php echo $thumbnail_url; ?>\" data-img=\"<?php echo $image_url[0]; ?>\" \/><\/pre>\n
$image_url =\u00a0wp_get_attachment_image_src( get_post_thumbnail_id(\u00a0$post_id\u00a0), 'large' );<\/pre>\n","protected":false},"excerpt":{"rendered":"