🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
在店面的产品的图像的属性存储在view.xml用配置文件英寸本主题提供有关属性可什么和如何配置它们的所有细节。 **配置view.xml用图片属性** view.xml用为主题的常规位置为: ~~~ <theme_dir>/etc/view.xml ~~~ 例如,下面是Magento的空白主题view.xml用: ~~~ app/design/frontend/Magento/blank/etc/view.xml ~~~ 在view.xml中图像属性中的范围<images module="Magento_Catalog"> ~~~ <images module="Magento_Catalog"> ... <images/> ~~~ 图像性能配置由元素的id和type属性定义的每个图像类型: ~~~ <images module="Magento_Catalog"> <image id="unique_image_id" type="image_type"> ... </image> <images/> ~~~ 下表详细介绍的属性: ~~~ id string 形象标识。独一无二的主题范围。 可为任意值,但外的任何─盒Magento的主题ID是有意义的,描述图像的位置。 例如,id值对于交叉销售产品图像购物卡显示为cart_cross_sell_products。 的ID在一个.phtml模板用于定义类型和特定的页面上显示在每个特定位置的图像的属性。 ~~~ ~~~ 该类型由指定ID定义的图像。允许值: image - 对应于Magento管理基础映像作用 small_image - 对应于Magento管理的小角色形象 swatch_image - 对应于Magento管理斯沃琪形象的作用 swatch_thumb - 对应于Magento管理斯沃琪形象的作用。 thumbnail - 对应于Magento管理缩略图作用 ~~~ 图像属性由相应的元件定义,例如: ~~~ <images module="Magento_Catalog"> <image id="unique_image_id" type="image"> <width>100</width> <!-- Image width in px --> <height>100</height> <!-- Image height in px --> </image> </images> ~~~ 下表包含了可配置的所有属性的列表: ~~~ 属性 类型 描述 需要 width integer Image width in pixels. Optional height integer Image height in pixels. Optional constrain boolean If set to true, images that are smaller than required by the configuration, are not enlarged. Default value: true. Optional aspect_ratio boolean If set to true, proportions of images are not changed even if required by the configuration. Default value: true. Optional frame boolean If set to true, images are not cropped. Default value: true. Applied only if aspect_ratio is set to true. Optional transparency boolean If set to true, the transparent background of images is saved. If is set to false, images have the white background (by default). You can set the color for the background using the background parameter. Default value: true. Optional background array The color for the images background. Not applied to images with transparency, if transparency is set to true. Optional ~~~ **调整目录图片** Magento的catalog:images:resize,您可以将图像尺寸调整为您的店面展示;例如: 导入产品后,可能具有可变大小的图像 如果图像大小或从缓存中手动删除 分配给产品的每个图像必须根据在模块的view.xml用配置文件定义的图像的元数据的大小。调整图像大小后,它的大小副本存储在缓存中(/pub/media/catalog/product/cache目录)。 Magento的从缓存中提供店面形象 一般情况下,同时节省了产品的产品图片被缓存。不过,有时你可能需要重新创建一个使用此命令,例如产品图片缓存,进口产品后,如果图像手动调整在缓存中,或者如果缓存被错误手动清除。 命令的用法: php <magento install dir>/bin/magento catalog:images:resize 该命令没有参数或选项。一个进度指示器显示的同时运行该命令。 成功地调整消息产品图片显示Product images resized successfully,以确认命令成功。