thelia/image-factory-module

安装: 299

依赖: 0

建议者: 0

安全: 0

星星: 0

关注者: 6

分支: 4

开放问题: 0

类型:thelia-module

0.4.3 2016-09-29 12:33 UTC

This package is auto-updated.

Last update: 2024-09-14 22:14:08 UTC


README

本模块为Thelia提供了一种管理图像的替代方案。

安装

手动

  • 将模块复制到<thelia_root>/local/modules/目录,并确保模块名称为ImageFactory。
  • 在thelia管理面板中激活它

Composer

将其添加到主thelia composer.json文件中

composer require thelia/image-factory-module:~0.4.0

用法

使用Smarty

{* With product id *}
<ul>
  {image_factory attr=['class'=> 'example-1'] code='test' view="product" view_id="325" inner="<li>?</li>" limit=10}
</ul>

{* With product sale element id *}
<ul>
  {image_factory attr=['class'=> 'example-1'] code='test' view="product_sale_element" view_id="21" inner="<li>?</li>" limit=10}
</ul>

{* With image id *}
<ul>
  {image_factory attr=['class'=> 'example-2'] code='test' view="product" image_id="10,11,12,13,14" inner="<li>?</li>"}
</ul>

{* With image file name *}
<ul>
  {image_factory attr=['class'=> 'example-3'] code='test' file_name="sample-image-394.png,sample-image-396.png" inner="<li>?</li>"}
</ul>

{* With force image not found *}
<ul>
  {image_factory force_not_found=true code='test' file_name="an-image-which-does-not-exist"}
</ul>


{* With an variable *}

{image_factory out="images" force_not_found=true code='test' file_name="an-image-which-does-not-exist"}

{$images|var_dump} {* $images is an collection of type ImageFactory\Response\FactoryResponseCollection *}
{$images[0]|var_dump} {* $images[0] is an object of type ImageFactory\Response\FactoryResponse *}

{* It's possibale to iterate on the collection *}

{foreach from=$images key=k item=image}
 {$image|var_dump}
{/foreach}

{* The object FactoryEntity implements the method __toString. This method returns the html code. *}

{foreach from=$images key=k item=image}
 {$image} {* Display the html code *}
{/foreach}

使用PHP

    /** @var \ImageFactory\Handler\FactoryHandler $factoryHandler */
    $factoryHandler = $this->getContainer()->get('image_factory.factory_handler');

    $image = ProductImageQuery::create()->findOne();
    $factoryCode = 'test';

    $url = $factoryHandler->getUrl($factoryCode, null, 'path/your/image');
    $url = $factoryHandler->getUrl($factoryCode, $image);

    $uri = $factoryHandler->getUri($factoryCode, null, 'path/your/image');
    $uri = $factoryHandler->getUri($factoryCode, $image);

命令

image-factory:generate-destination命令

用于生成特定工厂的所有图像

    php Thelia image-factory:generate-destination product-high,product-medium,product-small

或所有工厂的图像

    php Thelia image-factory:generate-destination "*"

使用此命令,不会重新生成已存在于目标路径上的图像。可以通过添加选项--force来强制生成过程。

    php Thelia image-factory:generate-destination product-high,product-medium,product-small --force

image-factory:reload-factory命令

用于重新加载缓存中的所有工厂

    php Thelia image-factory:reload-factory

在数据库中配置您的工厂(表image_factory)

待办事项

  • 后台管理界面上的配置界面