Magento2 przechowuje domyślną konfigurację layoutu, dotyczącą m.in. obrazków w pliku view.xml. Plik ten znajduje się w katalogu z motywem: Luma lub Blank:
1 2 |
vendor/magento/theme-frontend-luma/etc/view.xml vendor/magento/theme-frontend-blank/etc/view.xml |
Oczywiście vendor zostawiamy w spokoju 🙂
Aby nadpisać rozmiar obrazów z katalogu produktów, wystarczy skopiować plik view.xml z vendora do własnego motywu:
1 |
app/design/frontend/<Vendor>/<Theme> |
Przykład:
1 |
app/design/frontend/Geek/Basic/etc/view.xml |
Zawartość pliku aktualizujemy do postaci, która nas interesuje, czyli np:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?xml version="1.0"?> <!-- /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ --> <view xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/view.xsd"> <media> <images module="Magento_Catalog"> <image id="category_page_grid" type="small_image"> <width>300</width> <height>300</height> </image> </images> </media> </view> |
W tym przypadku wszystkie małe obrazy (type=”small_image”) z siatki produktów (id=”category_page_grid”) będą miały rozmiar 300 / 300 pikseli.
A poniżej zawartość pliku z wszystkimi typami obrazów, które możemy zmienić:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
<?xml version="1.0"?> <!-- /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ --> <view xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/view.xsd"> <media> <images module="Magento_Catalog"> <image id="bundled_product_customization_page" type="thumbnail"> <width>140</width> <height>140</height> </image> <image id="cart_cross_sell_products" type="small_image"> <width>240</width> <height>300</height> </image> <image id="cart_page_product_thumbnail" type="small_image"> <width>165</width> <height>165</height> </image> <image id="category_page_grid" type="small_image"> <width>240</width> <height>300</height> </image> <image id="category_page_grid-1" type="small_image"> <width>240</width> <height>300</height> </image> <image id="category_page_list" type="small_image"> <width>240</width> <height>300</height> </image> <image id="customer_account_my_tags_tag_view" type="small_image"> <width>100</width> <height>100</height> </image> <image id="customer_account_product_review_page" type="image"> <width>285</width> <height>285</height> </image> <image id="customer_shared_wishlist" type="small_image"> <width>113</width> <height>113</height> </image> <image id="gift_messages_checkout_small_image" type="small_image"> <width>75</width> <height>75</height> </image> <image id="gift_messages_checkout_thumbnail" type="thumbnail"> <width>100</width> <height>100</height> </image> <image id="mini_cart_product_thumbnail" type="thumbnail"> <width>75</width> <height>75</height> </image> <image id="new_products_content_widget_grid" type="small_image"> <width>240</width> <height>300</height> </image> <image id="new_products_content_widget_list" type="small_image"> <width>270</width> <height>340</height> </image> <image id="new_products_images_only_widget" type="small_image"> <width>78</width> <height>78</height> </image> <image id="product_base_image" type="image"> <width>265</width> <height>265</height> </image> <image id="product_comparison_list" type="small_image"> <width>140</width> <height>140</height> </image> <image id="product_page_image_large" type="image"/> <image id="product_page_image_large_no_frame" type="image"> <frame>false</frame> </image> <image id="product_page_image_medium" type="image"> <width>700</width> <height>560</height> </image> <image id="product_page_image_medium_no_frame" type="image"> <width>700</width> <height>700</height> <frame>false</frame> </image> <image id="product_page_image_small" type="thumbnail"> <width>88</width> <height>110</height> </image> <image id="product_page_main_image" type="image"> <width>700</width> <height>560</height> </image> <image id="product_page_main_image_default" type="image"> <width>700</width> <height>560</height> </image> <image id="product_page_more_views" type="thumbnail"> <width>88</width> <height>110</height> </image> <image id="product_stock_alert_email_product_image" type="small_image"> <width>76</width> <height>76</height> </image> <image id="product_small_image" type="small_image"> <width>135</width> <height>135</height> </image> <image id="product_thumbnail_image" type="thumbnail"> <width>75</width> <height>75</height> </image> <image id="recently_compared_products_grid_content_widget" type="small_image"> <width>240</width> <height>300</height> </image> <image id="recently_compared_products_images_names_widget" type="thumbnail"> <width>75</width> <height>90</height> </image> <image id="recently_compared_products_images_only_widget" type="thumbnail"> <width>76</width> <height>76</height> </image> <image id="recently_compared_products_list_content_widget" type="small_image"> <width>270</width> <height>340</height> </image> <image id="recently_viewed_products_grid_content_widget" type="small_image"> <width>240</width> <height>300</height> </image> <image id="recently_viewed_products_images_names_widget" type="small_image"> <width>75</width> <height>90</height> </image> <image id="recently_viewed_products_images_only_widget" type="small_image"> <width>76</width> <height>76</height> </image> <image id="recently_viewed_products_list_content_widget" type="small_image"> <width>270</width> <height>340</height> </image> <image id="related_products_list" type="small_image"> <width>152</width> <height>190</height> </image> <image id="review_page_product_image" type="small_image"> <width>285</width> <height>285</height> </image> <image id="rss_thumbnail" type="thumbnail"> <width>75</width> <height>75</height> </image> <image id="sendfriend_small_image" type="small_image"> <width>75</width> <height>75</height> </image> <image id="shared_wishlist_email" type="small_image"> <width>135</width> <height>135</height> </image> <image id="side_column_widget_product_thumbnail" type="thumbnail"> <width>75</width> <height>90</height> </image> <image id="upsell_products_list" type="small_image"> <width>135</width> <height>135</height> </image> <image id="wishlist_sidebar_block" type="thumbnail"> <width>75</width> <height>90</height> </image> <image id="wishlist_small_image" type="small_image"> <width>113</width> <height>113</height> </image> <image id="wishlist_thumbnail" type="small_image"> <width>240</width> <height>300</height> </image> </images> </media> </view> |
Na koniec musimy ponownie wygenerować grafiki na stronie:
1 |
$php bin/magento catalog:images:resize |
I wyczyścić cache:
1 |
$php bin/magento cache:clean |