承接 waughj/html-picture 相关项目开发

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

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

waughj/html-picture

Composer 安装命令:

composer require waughj/html-picture

包简介

Simple class for easy generation o' picture tag HTML code.

README 文档

README

Class for easy generation o' picture tag HTML code.

Use

Arguments for constructor:

  1. Fallback image as HTMLImage object.
  2. Sources as array o' HTMLPictureSource objects.
  3. Array o' picture element attributes.

A simpler way to generate these is to use the "generate" static method, which takes the following arguments:

  1. String representing base local filename ( don't include extension ).
  2. String representing extension ( don't include "."" ).
  3. Hash map with optional arguments:
    1. "loader": file loader to help set URL directory in which 1st argument will be treated local to & the server directory for getting the modified date o' the file to break cache corruption. See https://github.com/waughjai/file-loader for mo' info on how to use this. Can be hash map or FileLoader object.
    2. "img-attributes": HTML attributes that will go in the img tag ( these will affect the image that is shown ).
    3. "picture-attributes": HTML attributes that will go in containing picture tag.
    4. "source-attributes": HTML attributes that will go in every source tag. You probably won't need this. Don't use ID, as it will create multiple IDs, which is invalid.

Example

use WaughJ\HTMLPicture\HTMLPicture;

echo HTMLPicture::generate
(
	'photo',
	'jpg',
	'480w 320h, 800w 600h, 1200w 800h',
	[
		'loader' =>
		[
			'directory-url' => 'https://mywebsite.com',
			'directory-server' => getcwd(),
			'shared-directory' => 'tests'
		],
		'img-attributes' => [ 'class' => 'center-img' ],
		'picture-attributes' => [ 'id' => 'slider-42' ],
		'source-attributes' => [ 'class' => 'source-item' ]
	]
);

Will print ( #s after "?m=" will vary ):

<picture id="slider-42"><source class="source-item" srcset="https://mywebsite.com/tests/photo-480x320.jpg?m=1543530332" media="(max-width:480px)"><source class="source-item" srcset="https://mywebsite.com/tests/photo-800x600.jpg?m=1543530717" media="(max-width:800px)"><source class="source-item" srcset="https://mywebsite.com/tests/photo-1200x800.jpg?m=1543530725"><img src="https://mywebsite.com/tests/photo-480x320.jpg?m=1543530332" class="center-img" alt="" /></picture>

Error Handling

PictureHTML's default o' adding a version to each URL may throw a WaughJ\FileLoader\MissingFileException exception when using the static generate method ( but not the regular constructor, which doesn't set any URLs ). This exception contains a fallback version o' the PictureHTML that is equivalent to a version with "show_version" turned off.

Example:

$picture = null;
try
{
	$picture = HTMLPicture::generate
	(
		'iainthere',
		'jpg',
		[
			[ 'w' => 480, 'h' => '320' ],
			[ 'w' => 800, 'h' => 600 ],
			[ 'w' => '1200', 'h' => 800 ]
		],
		[
			'loader' => [ 'directory-url' => 'https://mywebsite.com', 'directory-server' => getcwd(), 'shared-directory' => 'tests' ]
		]
	);
}
catch ( MissingFileException $e )
{
	$picture = $e->getFallbackContent();
}

Changelog

0.7.0

  • Add Cached HTML to Make Use o' Same Object Multiple Times Faster

0.6.0

  • Revamp Error Handling for Missing Files

0.5.0

  • Add Ability to Easily Cancel Showing Versioning

0.4.0

  • Add getSources & getPictureAttributes Methods

0.3.0

  • Change Constructor to Take in HTMLImage & Array o' HTMLPictureSource

0.2.0

  • Add getFallbackImage & changeFallbackImage Methods

0.1.0

  • Initial Version

waughj/html-picture 适用场景与选型建议

waughj/html-picture 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 154 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 11 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「generator」 「html」 「picture tag」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 waughj/html-picture 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 waughj/html-picture 我们能提供哪些服务?
定制开发 / 二次开发

基于 waughj/html-picture 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: AGPL-3.0-or-later
  • 更新时间: 2018-11-29