定制 aeyoll/image_retriever 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aeyoll/image_retriever

Composer 安装命令:

composer require aeyoll/image_retriever

包简介

Image Retriever for PrestaShop

README 文档

README

This module helps you generate thumbnails and webp/avif alternatives for images inside a custom module.

Requirements

PHP 7.1+ is needed to use this module.

Installation

PrestaShop 8.0+

For PrestaShop 8.0+, require the plugin with Composer using the following command:

composer require aeyoll/image_retriever

Usage

Let's assume you have an image file in a module, located at modules/your_module/img/test.jpg.

<?php

use PrestaShop\Module\ImageRetriever\Service\ImageRetrieverService;

$irs = new ImageRetrieverService();
$image = $irs->getImage(
    _PS_MODULE_DIR_ . 'your_module/img/', // The absolute path to the uploaded images folder
    'test.jpg', // The image filename
    ['home_default'] // Optional: generate only specific image types, otherwise generate every format
);

In your template:

<picture>
    {if !empty($image.bySize.home_default.sources.avif)}
        <source srcset="{$image.bySize.home_default.sources.avif}" type="image/avif">
    {/if}

    {if !empty($image.bySize.home_default.sources.webp)}
        <source srcset="{$image.bySize.home_default.sources.webp}" type="image/webp">
    {/if}

    <img
        class="img-fluid"
        src="{$image.bySize.home_default.url}"
        alt=""
        width="{$image.bySize.home_default.width}"
        height="{$image.bySize.home_default.height}">
</picture>

统计信息

  • 总下载量: 65
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-02-13