{"id":4372,"date":"2017-10-03T11:24:04","date_gmt":"2017-10-03T11:24:04","guid":{"rendered":"http:\/\/musilda.cz\/?p=4372"},"modified":"2017-10-03T11:24:04","modified_gmt":"2017-10-03T11:24:04","slug":"vite-woocommerce-pracuje-obrazky-eshopu","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/vite-woocommerce-pracuje-obrazky-eshopu\/","title":{"rendered":"V\u00edte jak WooCommerce pracuje s obr\u00e1zky v eshopu?"},"content":{"rendered":"\n
Na posledn\u00edm \u0161kolen\u00ed jsem se pokou\u0161el vysv\u011btlit, jak WooCommerce pracuje s obr\u00e1zky a pro\u010d to v\u017edy nedopadne tak jak chcete.<\/p>\n\n\n\n
Proto\u017ee m\u00e9 vysv\u011btlen\u00ed bylo pro n\u011bkter\u00e9 z \u00fa\u010dastn\u00edk\u016f komplikovan\u00e9 a matouc\u00ed, p\u0159ipravil jsem tento \u010dl\u00e1nek, s n\u011bkolika uk\u00e1zkami a vysv\u011btlen\u00edm, r\u016fzn\u00fdch p\u0159\u00edklad\u016f.<\/p>\n\n\n\n
P\u0159esto\u017ee se budeme zab\u00fdvat obr\u00e1zky, jen\u017e pou\u017e\u00edv\u00e1 WooCommerce, mus\u00edme si nejprve popsat, jak funguje vytv\u00e1\u0159en\u00ed obr\u00e1zk\u016f ve WordPressu. <\/span><\/p>\n\n\n\n WooCommerce toti\u017e pou\u017e\u00edv\u00e1 mechanizmus, defaultn\u011b poskytovan\u00fd pr\u00e1v\u011b WordPressem.<\/span><\/p>\n\n\n\n Proto\u017ee budeme pou\u017e\u00edvat pojem velikost obr\u00e1zku, je nutno \u0159\u00edci, \u017ee se jedn\u00e1 o velikost v pixelech, tedy \u0161\u00ed\u0159ku a v\u00fd\u0161ku a ne datovou velikost obr\u00e1zku, co\u017e m\u016f\u017ee b\u00fdt t\u0159eba 600 kb.<\/span><\/p>\n\n\n\n Pust\u00edme se tedy do pr\u00e1ce s obr\u00e1zky.<\/span><\/p>\n\n\n\n Nez\u00e1le\u017e\u00ed na tom, zda obr\u00e1zek vkl\u00e1d\u00e1te do postu, nebo jej nahr\u00e1v\u00e1te do knihovny m\u00e9di\u00ed. WordPress p\u0159i ka\u017ed\u00e9m nahr\u00e1v\u00e1n\u00ed ulo\u017e\u00ed origin\u00e1l nahr\u00e1van\u00fd do syst\u00e9mu do slo\u017eky wp-content\/uploads\/slozka-aktualniho-mesice a vygeneruje k n\u011bmu takzvan\u00e9 n\u00e1hledy.<\/span><\/p>\n\n\n\n Jsou \u010dty\u0159i:<\/span><\/p>\n\n\n\n Toto WordPress ud\u011bl\u00e1 v\u017edy. <\/span><\/p>\n\n\n\n Po nahr\u00e1n\u00ed obr\u00e1zku tak je ve slo\u017ece rovnou p\u011bt obr\u00e1zk\u016f. <\/span><\/p>\n\n\n\n A co WooCommerce?<\/strong><\/p>\n\n\n\n Ta k tomu p\u0159id\u00e1 dal\u0161\u00ed t\u0159i:<\/span><\/p>\n\n\n\n Z\u00e1m\u011brn\u011b neuv\u00e1d\u00edm rozm\u011bry, proto\u017ee ve WooCommerce m\u00e1te mo\u017enost velikost obr\u00e1zk\u016f nastavovat dle sv\u00e9ho uv\u00e1\u017een\u00ed. <\/span><\/p>\n\n\n\n D\u00edky tomu, \u017ee obr\u00e1zek, jen\u017e nahr\u00e1v\u00e1te, m\u016f\u017ee m\u00edt jak\u00fdkoliv rozm\u011br a orientaci, \u010dasto se st\u00e1v\u00e1, \u017ee obr\u00e1zky produkt\u016f nejsou stejn\u011b velik\u00e9 a eshop pak p\u016fsob\u00ed rozh\u00e1zen\u011b.<\/span><\/p>\n\n\n Poj\u010fme si vysv\u011btlit, pro\u010d tomu tak je. <\/span><\/p>\n\n\n\n Ka\u017ed\u00fd obr\u00e1zek, jen\u017e do syst\u00e9mu nahrajete, je \u201co\u0159ez\u00e1n\u201d. Sice ne v\u017edy, jak si pozd\u011bji vysv\u011btl\u00edme, ale zat\u00edm n\u00e1m to sta\u010d\u00ed. <\/span><\/p>\n\n\n\n A ka\u017ed\u00fd o\u0159ez, mus\u00edme za\u010d\u00edt odn\u011bkud m\u011b\u0159it. WordPress za\u010dne naho\u0159e uprost\u0159ed. Pro p\u0159edstavu p\u0159ikl\u00e1d\u00e1m screen z pluginu, jen\u017e um\u00ed nastavit po\u010d\u00e1te\u010dn\u00ed sou\u0159adnice o\u0159ezu:<\/span><\/p>\n\n\n Ne\u017e za\u010dneme pracovat s p\u0159\u00edklady, mus\u00edm je\u0161t\u011b uv\u00e9st, \u017ee o\u0159ez m\u016f\u017ee b\u00fdt hard, nebo soft. <\/span><\/p>\n\n\n\n A podle toho se dost li\u0161\u00ed v\u00fdsledek. <\/span><\/p>\n\n\n\n Nejprve si stanov\u00edme rozm\u011bry. Budeme pracovat s v\u00fdsledn\u00fdm obr\u00e1zkem 600×800 pixel\u016f, tedy obr\u00e1zkem na v\u00fd\u0161ku. <\/span><\/p>\n\n\n\n WordPress se sna\u017e\u00ed vyplnit prostor, ur\u010den\u00fd pro obr\u00e1zek beze zbytku a proto vezme nejkrat\u0161\u00ed stranu a uprav\u00ed ji tak, aby odpov\u00eddala rozm\u011bru, v na\u0161em p\u0159\u00edpad\u011b 600 px. <\/span><\/p>\n\n\n\n Pro lep\u0161\u00ed pochopen\u00ed jsem pou\u017eil r\u00e1me\u010dek, tak\u017ee si p\u0159edstavte, \u017ee do n\u011bj vkl\u00e1d\u00e1te fotografii.<\/span><\/p>\n\n\n A p\u0159i hard o\u0159ezu, je v\u0161e co p\u0159e\u010duhuje o\u0159\u00edznuto:<\/span><\/p>\n\n\n A co se stane, pokud vlo\u017e\u00edme obr\u00e1zek na \u0161\u00ed\u0159ku?<\/span><\/p>\n\n\n WordPress op\u011bt na\u0161el nejmen\u0161\u00ed stranu, tentokr\u00e1t je to v\u00fd\u0161ka a upravil obr\u00e1zek tak, aby n\u00e1m r\u00e1me\u010dek vyplnill beze zbytku. <\/span><\/p>\n\n\n\n V\u00fdsledek:<\/span><\/p>\n\n\n N\u011bco chyb\u00ed, ne? Podobn\u011b, jako u p\u0159edchoz\u00edho p\u0159\u00edkladu, co je mimo r\u00e1me\u010dek, je o\u0159\u00edznuto. <\/span><\/p>\n\n\n\n V p\u0159\u00edpad\u011b, \u017ee nechcete, aby v\u00e1m syst\u00e9m o\u0159ez\u00e1val fotografie, mus\u00edte je p\u0159i hard o\u0159ezu vkl\u00e1dat v p\u0159esn\u00e9m pom\u011bru stran. Pro tento p\u0159\u00edklad to je 3:4. Obr\u00e1zek, kter\u00fd bude 1353×1804 pixel\u016f, bude zmen\u0161en p\u0159esn\u011b na 600×800.<\/span><\/p>\n\n\n\n Nyn\u00ed bude WordPress postupovat obr\u00e1cen\u011b. Najde nejv\u011bt\u0161\u00ed rozm\u011br – to je v\u00fd\u0161ka a uprav\u00ed ji tak, aby vyplnila r\u00e1me\u010dek. Zde jsem do obr\u00e1zku p\u0159idal barevn\u00e9 pozad\u00ed, aby bylo vid\u011bt, co se stalo:<\/span><\/p>\n\n\n Jak vid\u00edte, obr\u00e1zek na v\u00fd\u0161ku vypl\u0148uje r\u00e1me\u010dek, ale proto\u017ee se WordPress sna\u017e\u00ed neo\u0159ez\u00e1vat, \u0161\u00ed\u0159ka je men\u0161\u00ed ne\u017e velikost r\u00e1me\u010dku. Na druhou stranu je obr\u00e1zek kompletn\u00ed.<\/span><\/p>\n\n\n\n Poj\u010fme se nyn\u00ed pod\u00edvat, co se stane, pokud p\u0159i soft o\u0159ezu, nahrajeme obr\u00e1zek orientovan\u00fd na \u0161\u00ed\u0159ku:<\/span><\/p>\n\n\n Co\u017e asi tak\u00e9 nen\u00ed zcela ide\u00e1ln\u00ed. <\/span><\/p>\n\n\n\n Jak z toho ven?<\/span><\/p>\n\n\n\n V podstat\u011b jsou 3 mo\u017enosti<\/strong>.<\/span><\/p>\n\n\n\n M\u011bjte v\u0161echny obr\u00e1zky p\u0159ipraven\u00e9 ve stejn\u00e9 velikosti, orientaci a pom\u011bru stran. <\/span><\/p>\n\n\n\n Pokud nejsou podkladov\u00e9 obr\u00e1zky stejn\u00e9, m\u016f\u017eete z nich stejn\u00e9 ud\u011blat. Vytvo\u0159\u00edte si v grafick\u00e9m editoru b\u00edl\u00e9 pozad\u00ed v rozm\u011bru\/pom\u011bru, odpov\u00eddaj\u00edc\u00ed tomu definovan\u00e9mu a obr\u00e1zek do n\u011bj um\u00edst\u00edte t\u0159eba doprost\u0159ed:<\/span><\/p>\n\n\n V\u017edy to ale znamen\u00e1 n\u011bjakou pr\u00e1ci p\u0159i \u00faprav\u011b obr\u00e1zk\u016f. <\/span><\/p>\n\n\n\n Posledn\u00ed mo\u017enost, je nastavit jeden z rozm\u011br\u016f, p\u0159i soft o\u0159ezu na vysok\u00e9 \u010d\u00edslo. <\/strong><\/p>\n\n\n\n Tuto mo\u017enost pou\u017e\u00edv\u00e1m j\u00e1, abych p\u0159ede\u0161el probl\u00e9m\u016fm, p\u0159i drobn\u00fdch nesrovnalostech ve velikostech, v rozmez\u00ed pixel\u016f a soft proto, aby WordPress neo\u0159ez\u00e1val \u010d\u00e1sti obr\u00e1zk\u016f.<\/span><\/p>\n\n\n\n\n
\n
<\/a><\/figure><\/div>\n\n\n
<\/a><\/figure><\/div>\n\n\n
P\u0159\u00edklady o\u0159ezu obr\u00e1zku<\/h2>\n\n\n\n
P\u0159\u00edklad 1 – hard o\u0159ez, obr\u00e1zek orientovan\u00fd na v\u00fd\u0161ku.<\/h2>\n\n\n\n
<\/a><\/figure><\/div>\n\n\n
<\/a><\/figure><\/div>\n\n\n
P\u0159\u00edklad 2 – hard o\u0159ez, obr\u00e1zek orientovan\u00fd na \u0161\u00ed\u0159ku<\/strong><\/h2>\n\n\n\n
<\/a><\/figure><\/div>\n\n\n
<\/a><\/figure><\/div>\n\n\n
P\u0159\u00edklad 3 – soft o\u0159ez, obr\u00e1zek na v\u00fd\u0161ku<\/strong><\/h2>\n\n\n\n
<\/a><\/figure><\/div>\n\n\n
P\u0159\u00edklad 4 – soft o\u0159ez, obr\u00e1zek na \u0161\u00ed\u0159ku<\/strong><\/h2>\n\n\n\n
<\/a><\/figure><\/div>\n\n\n
<\/a><\/figure><\/div>\n\n\n