定制 waughj/wp-theme-picture 二次开发

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

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

waughj/wp-theme-picture

Composer 安装命令:

composer require waughj/wp-theme-picture

包简介

Class for autogenerating picture tag HTML for WordPress theme image.

README 文档

README

Class for autogenerating picture tag HTML for WordPress theme image.

Works just like HTMLPicture, but automatically applies WPThemeImage directory rather than expecting users to supply their own.

For a theme named “example” setup on https://www.example.com:

use WaughJ\WPThemePicture\WPThemePicture;

$picture = new WPThemePicture( 'photo', 'jpg', '320w 240h, 800w 400h, 1200w 800h', [ 'directory' => 'img' ] );
$picture->print();

//    Will print out the following ( #s after m?= will vary ):
//    <picture>
//        <source srcset="https://www.example.com/wp-content/themes/example/img/photo-320x240.jpg?m=1554999461" media="(max-width:320px)">
//        <source srcset="https://www.example.com/wp-content/themes/example/img/photo-800x400.jpg?m=1554999461" media="(max-width:800px)">
//        <source srcset="https://www.example.com/wp-content/themes/example/img/photo-1200x800.jpg?m=1554999461" media="(min-width:801px)">
//        <img src="https://www.example.com/wp-content/themes/example/img/photo-320x240.jpg?m=1554999461" alt="" />
//    </picture>

Like HTMLPicture, this will throw a MissingFileException if versioning is set on ( the default ) & the server can’t find the file. Look @ the HTMLPicture documentation for mo’ information.

An easy way to deal with exceptions:

use WaughJ\FileLoader\MissingFileException;
use WaughJ\WPThemePicture\WPThemePicture;

try
{
	$picture = new WPThemePicture( 'photo', 'jpg', '320w 240h, 800w 400h, 1200w 800h, 2400w 600h', [ 'directory' => 'img' ] );
}
catch ( MissingFileException $e )
{
	$picture = $e->getFallbackContent();
}

$picture->print(); // Will print without versioning for files that can’t be found & won’t throw exception.

Changelog

0.3.0

  • Update to Newest Version o’ HTMLPicture

0.2.0

  • Make compatible with new HTMLPicture code

0.1.0

  • Initial Release

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固