ankitpokhrel / dynamic-featured-image
动态添加多个特色图片(文章缩略图)功能到文章、页面和自定义文章类型。
v3.7.0
2019-04-14 09:30 UTC
Requires (Dev)
- phpunit/phpunit: ~5.7
README
动态特色图片(WordPress插件)
此项目不再积极维护。
动态添加多个特色图片(文章缩略图)功能到文章、页面和自定义文章类型。
概述
为什么只限制自己使用一个特色图片,如果你可以用多个特色图片做一些很棒的事情?动态特色图片插件允许在一个文章或页面上有多个特色图片。它允许你为每个文章和页面添加不同数量的特色图片,这些图片可以被各种主题功能收集。当你使用其他插件、文章缩略图或使用特色图片的滑块时,这特别有用。
安装
- 解压缩并将
dynamic-featured-images
目录上传到插件目录(/wp-content/plugins/
)或从插件->添加新插件->上传
安装。 - 通过WordPress中的
插件
菜单激活插件。 - 如果你看不到新的特色图片框,点击wordpress管理员右上角的
屏幕选项
,确保选中了特色图片2
框。
Bower
bower install dynamic-featured-image
它如何工作?
- 在成功激活插件后,转到文章或页面的
添加
或编辑
页面,你会注意到一个用于第二张特色图片的框。
- 点击
设置特色图片
图标,从“动态特色图片媒体选择器”弹出窗口选择所需的图片,然后点击设置特色图片
。
- 点击
添加新
以添加新的特色图片或使用删除
链接删除特色图片框。
- 添加特色图片后,点击
发布
或更新
以保存特色图片。
注意:只有在你发布或更新文章时才会保存特色图片。
文档
其他资源
可用函数列表
- get_image_id( $image_url )
- get_image_thumb( $image_url, $size = "thumbnail" )
- get_image_url( $attachment_id, $size = "full" )
- get_post_attachment_ids( $post_id )
- is_attached( $attachment_id, $post_id )
- get_image_title( $image_url )
- get_image_title_by_id( $attachment_id )
- get_image_alt( $image_url )
- get_image_alt_by_id( $attachment_id )
- get_image_caption( $image_url )
- get_image_caption_by_id( $attachment_id )
- get_image_description( $image_url )
- get_image_description_by_id( $attachment_id )
- get_nth_featured_image( $position, $post_id )
- get_all_featured_images( $post_id )
- get_featured_images( $post_id )
- get_link_to_image( $attachment_id )
仅在特定文章类型中允许DFI
你可以使用dfi_post_types
过滤器仅允许在特定文章类型中使用DFI。
function allowed_post_types() {
return array('post'); //show DFI only in post
}
add_filter('dfi_post_types', 'allowed_post_types');
阻止DFI
使用dfi_post_type_user_filter
过滤器阻止DFI从文章类型中。
function blocked_post_types() {
return array('page'); //block DFI in page
}
add_filter('dfi_post_type_user_filter', 'blocked_post_types');
更改元框默认文本
使用dfi_set_metabox_title
过滤器更改元框默认标题(特色图片)
function set_metabox_title( $title ) {
return "My custom metabox title";
}
add_filter('dfi_set_metabox_title', 'set_metabox_title');
翻译指南
所有翻译都存储在languages
文件夹中。
如果你有兴趣将插件翻译成你的语言,首先确保翻译尚未可用。文件名很重要,因为需要遵循特定的格式以保持一致性。例如,如果你要将尼泊尔语翻译成尼泊尔,文件应该是dynamic-featured-image-ne_NP.po
– dynamic-featured-image
用于插件本身,ne
用于语言,NP
用于国家。
开发
- 如果您还没有安装,请安装PHPUnit和composer。
- 安装所需依赖项
$ composer install
- 使用安装脚本构建测试
$ ./bin/install-wp-tests.sh <test-db-name> <db-user> <db-pass> [db-host] [wp-version] [skip-database-creation]
- 使用phpunit运行测试
$ ./vendor/bin/phpunit
- 将更改与WordPress编码标准进行验证
$ phpcs <dfi-plugin-dir or filename>
关于这个项目有任何疑问吗?
请随时报告发现的任何错误。拉取请求、问题报告和插件推荐都欢迎!