waughj/wp-theme-image 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

waughj/wp-theme-image

Composer 安装命令:

composer require waughj/wp-theme-image

包简介

Class for autogenerating HTML for WordPress theme image.

README 文档

README

Class for autogenerating HTML for WordPress theme image.

Works just like HTMLImage class, but autogenerates the FileLoader to fit WordPress’s theme directory.

Local directory within theme directory can be set on an image-by-image basis by setting the “directory” key in the $attributes hash map to the desired local directory string.

For example, in a theme named “blue” setup on localhost:

use WaughJ\WPThemeImage\WPThemeImage;

$image = new WPThemeImage( 'demo.png', [ 'directory' => 'img' ] );
$image->print(); // Will print <img src="http://localhost.com/wp-content/themes/blue/img/demo.png?m=4389109" alt=""> ( #s after m= will vary ).

Or you can globally set the default local directory with the static method setDefaultSharedDirectory():

use WaughJ\WPThemeImage\WPThemeImage;

$image = new WPThemeImage( 'demo.png' );
$image->print(); // Will print <img src="http://localhost.com/wp-content/themes/blue/demo.png?m=4389109" alt=""> ( #s after m= will vary ).

WPThemeImage::setDefaultSharedDirectory( 'pictures' );

$image = new WPThemeImage( 'demo.png' );
$image->print(); // Will now print <img src="http://localhost.com/wp-content/themes/blue/pictures/demo.png?m=4389109" alt=""> ( #s after m= will vary ).

Error Handling

As a child o’ HTMLImage, WPThemeImage will throw an exception if it’s set to show versioning ( default ) & can’t find the file on the server. Read the HTMLImage documentation to learn mo’ ’bout this. WPThemeImage works the same way:

try
{
	$image = new WPThemeImage( 'missing.jpg' );
}
catch ( MissingFileException $e )
{
	$image = $e->getFallbackContent();
}
$image->print() // Will print <img src="http://localhost.com/wp-content/themes/blue/missing.jpg" alt=""> without throwing an error.

Changelog

0.4.0

  • Add function for getting URL directory.

0.3.0

  • Integrate HTMLImage Autogeneration o’ Sizes Attribute & Shorthand Srcset Format

0.2.0

  • Apply HTMLImage HTML Cache Optimization

0.1.0

  • Initial Release

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固