{"id":1259,"date":"2013-10-31T17:17:05","date_gmt":"2013-10-31T17:17:05","guid":{"rendered":"http:\/\/musilda.cz\/?p=1259"},"modified":"2013-10-31T17:17:05","modified_gmt":"2013-10-31T17:17:05","slug":"jak-ziskat-vsechny-obrazky-prirazene-k-clanku","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/jak-ziskat-vsechny-obrazky-prirazene-k-clanku\/","title":{"rendered":"Jak z\u00edskat v\u0161echny obr\u00e1zky p\u0159i\u0159azen\u00e9 k \u010dl\u00e1nku?"},"content":{"rendered":"\n
Z\u00edsk\u00e1n\u00ed v\u0161ech obr\u00e1zk\u016f, kter\u00e9 jsou p\u0159i\u0159azen\u00e9 k \u010dl\u00e1nku nebo str\u00e1nce, m\u016f\u017eete vyu\u017e\u00edt pro vytvo\u0159en\u00ed n\u011bjak\u00e9ho slideru, t\u0159eba v sidebaru. S WordPressem 3.6 je k dispozici nov\u00e1 funkce, kter\u00e1 toto usnadn\u00ed. V \u010dl\u00e1nku v\u00e1m uk\u00e1\u017ei oba postupy, proto\u017ee na neaktualizovan\u00e9m webu nebude fungovat.<\/p>\n\n\n\n\n\n\n\n
P\u0159esto\u017ee v titulku zmi\u0148uji obr\u00e1zky, ale jedn\u00e1 se o v\u0161echny soubory (attachment), tedy i videa, zip soubory, pdf a dal\u0161\u00ed. Jednou z mo\u017enost\u00ed, jak tento postup vyu\u017e\u00edt m\u016f\u017ee b\u00fdt vyps\u00e1n\u00ed v\u0161ech pdf soubor\u016f, jen\u017e jsou p\u0159i\u0159azeny ke str\u00e1nce. Co\u017e se m\u016f\u017ee hodit, kdy\u017e chcete u\u017eivatel\u016fm nab\u00eddnout cen\u00edky ke sta\u017een\u00ed.<\/p>\n\n\n\n
Dal\u0161\u00ed mo\u017enost\u00ed je t\u0159eba vytvo\u0159en\u00ed slideru ze v\u0161ech obr\u00e1zk\u016f z \u010dl\u00e1nku, a\u0165 ji\u017e na hlavn\u00ed stran\u011b, nebo sidebaru.<\/p>\n\n\n\n
Do verze 3.6 bylo nutn\u00e9 pou\u017e\u00edt tento postup:<\/p>\n\n\n\n
$args = array(\n\t'post_parent' => $post->ID,\n\t'post_type' => 'attachment',\n\t'post_mime_type' => 'image',\n\t'posts_per_page' => -1,\n\t'orderby' => 'menu_order',\n\t'order' => 'ASC',\n);\n\n$attachments = get_children( $args );\n<\/pre>\n\n\n\nZa post_mime_type si dosa\u010fte typ souboru.<\/p>\n\n\n\n
Od verze 3.6 je k dispozici funkce get_attached_media(). D\u00edky n\u00ed z\u00edsk\u00e1te v\u0161echny soubory p\u0159i\u0159azen\u00e9 k \u010dl\u00e1nku:<\/p>\n\n\n\n
$attachments = get_attached_media( '', $post->ID );<\/pre>\n\n\n\nV\u0161echny obr\u00e1zky:<\/p>\n\n\n\n
$attachments = get_attached_media( 'image', $post->ID );<\/pre>\n\n\n\nV\u0161echny videa:<\/p>\n\n\n\n
$attachments = get_attached_media( 'video', $post->ID );<\/pre>\n\n\n\nV\u0161echny audio soubory:<\/p>\n\n\n\n
$attachments = get_attached_media( 'audio', $post->ID );<\/pre>\n\n\n\nVyu\u017eit\u00ed mne napad\u00e1 v\u00edce, m\u016f\u017eete t\u0159eba definovat pou\u017eit\u00ed prvn\u00edho obr\u00e1zku v \u010dl\u00e1nku jako n\u00e1hledov\u00fd obr\u00e1zek, pokud \u010dl\u00e1nek nem\u00e1 n\u00e1hledov\u00fd obr\u00e1zek vlo\u017een\u00fd. To se hod\u00ed, pokud m\u00e1te t\u0159eba v\u00edce redaktor\u016f.<\/p>\n","protected":false},"excerpt":{"rendered":"
Z\u00edsk\u00e1n\u00ed v\u0161ech obr\u00e1zk\u016f, kter\u00e9 jsou p\u0159i\u0159azen\u00e9 k \u010dl\u00e1nku nebo str\u00e1nce, m\u016f\u017eete vyu\u017e\u00edt pro vytvo\u0159en\u00ed n\u011bjak\u00e9ho slideru, t\u0159eba v sidebaru. S WordPressem 3.6 je k dispozici nov\u00e1 funkce, kter\u00e1 toto usnadn\u00ed. V \u010dl\u00e1nku v\u00e1m uk\u00e1\u017ei oba postupy, proto\u017ee na neaktualizovan\u00e9m webu nebude fungovat.<\/p>\n","protected":false},"author":1,"featured_media":8624,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,19],"tags":[],"class_list":["post-1259","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-navody","category-snippety"],"_links":{"self":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/1259"}],"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=1259"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/1259\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media\/8624"}],"wp:attachment":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media?parent=1259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=1259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=1259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}