{"id":1436,"date":"2014-01-19T20:42:39","date_gmt":"2014-01-19T20:42:39","guid":{"rendered":"http:\/\/musilda.cz\/?p=1436"},"modified":"2014-01-19T20:42:39","modified_gmt":"2014-01-19T20:42:39","slug":"funkce-get_post_mime_type","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/funkce-get_post_mime_type\/","title":{"rendered":"Funkce get_post_mime_type"},"content":{"rendered":"

Dal\u0161\u00ed funkce, kterou se budu v Codexu zab\u00fdvat, je get_post_mime_type(). Pomoc\u00ed n\u00ed a id postu m\u016f\u017eete zjistit jaky mime typ je aktu\u00e1ln\u00ed post. Co\u017e u v\u011bt\u0161iny druh\u016f obsahu je zbyte\u010dn\u00e9, ale u attachment to naopak smysl d\u00e1v\u00e1.\u00a0<\/p>\n

Jednodu\u0161e tak m\u016f\u017eete zjistit, o jak\u00fd typ souboru se jedn\u00e1 a pou\u017e\u00edt tuto informaci v podm\u00ednce, pro r\u016fzn\u00e9 grafick\u00e9 zobrazen\u00ed.<\/p>\n

Pro zobrazen\u00ed rozd\u00edln\u00fdch ikonek, pro pdf soubory, obr\u00e1zky dle typu, nebo medi\u00e1ln\u00edch soubor\u016f, lze vyu\u017e\u00edt funkci\u00a0wp_mime_type_icon(\u00a0$mime\u00a0), kde $mime je hodnota, kterou v\u00e1m vr\u00e1t\u00ed funkce get_post_mime_type.<\/p>\n

Pou\u017eit\u00ed:<\/h3>\n
\n$type = get_post_mime_type($post->ID);\nif($type != 'image\/jpeg'){ echo 'Tento soubor nen\u00ed jpeg obr\u00e1zek!'; }\n<\/pre>\n

Zobrazen\u00ed ikonky pro typ souboru:<\/strong><\/p>\n

\nID));\n?>\n<img src="\" \/>\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

Dal\u0161\u00ed funkce, kterou se budu v Codexu zab\u00fdvat, je get_post_mime_type(). Pomoc\u00ed n\u00ed a id postu m\u016f\u017eete zjistit jaky mime typ je aktu\u00e1ln\u00ed post. Co\u017e u v\u011bt\u0161iny druh\u016f obsahu je zbyte\u010dn\u00e9, ale u attachment to naopak smysl d\u00e1v\u00e1.\u00a0<\/p>\n","protected":false},"author":1,"featured_media":8523,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[7,15],"tags":[],"class_list":["post-1436","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-codex","category-post-funkce"],"_links":{"self":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/1436"}],"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=1436"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/1436\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media\/8523"}],"wp:attachment":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media?parent=1436"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=1436"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=1436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}