承接 hcesrl/php-responsive-image-sizes 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

hcesrl/php-responsive-image-sizes

最新稳定版本:1.0.3

Composer 安装命令:

composer require hcesrl/php-responsive-image-sizes

包简介

Retrieve the correct sizes for a responsive image based on its intrinsic width and its width on screen

README 文档

README

Installation

composer require hcesrl/php-responsive-image-sizes

Usage

Please refer to the original javascript library documentation for further informations: https://github.com/HCESrl/responsive-image-sizes

Here is a basic example:

<?php
use Hcesrl\PhpResponsiveImageSizes\BaseSizes;
use Hcesrl\PhpResponsiveImageSizes\DeviceType;
use Hcesrl\PhpResponsiveImageSizes\ResponsiveImagesSizes;

require 'vendor/autoload.php';

var_dump(ResponsiveImagesSizes::getResponsiveSizes(DeviceType::All(), new BaseSizes(BaseSizesType::Granular())));

ResponsiveImagesSizes::getResponsiveSizes function accepts following parameters:

  • $deviceType enum value: one of the available Enum DeviceType values (based on marc-mabe/php-enum library);
  • BaseSizes class instance: the constructor expects one of the available Enum BaseSizesType values (based on marc-mabe/php-enum library). If you choose BaseSizesType::Custom() value, a second parameter is expected (see below);
  • $sourceImageWidth integer, default is 3220, see js library docs for further informations;
  • $widthOnPage integer, default is 100, see js library docs for further informations;
  • $topSize integer, default is 1920, see js library docs for further informations;

if you want to use a custom set of BaseSizes, you should declare an array that matches the following schema, and use it as second BaseSizes class constructor's argument:

[
    'desktop' => [
        -- values --
    ],
    'tabletPortrait => [
        -- values --
    ],
    'smartphone' => [
        -- values --
    ]
]

Example:

$customSizes = [
    DeviceType::Desktop => [
      1440,
      1280,
      1024
    ],
    DeviceType::TabletPortrait => [
      1024,
      768
    ],
    DeviceType::Smartphone => [
      828,
      750,
      720,
      640
    ]
];
var_dump(ResponsiveImagesSizes::getResponsiveSizes(DeviceType::All(), new BaseSizes(BaseSizesType::Custom(), $customSizes)));

Output sample:

(
    [0] => 1024
    [1] => 1280
    [2] => 1440
)

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-10-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固