perchten/wordpress_attachmentfromimg
Composer 安装命令:
composer require perchten/wordpress_attachmentfromimg
包简介
Single function to get wordpress attachment id from an img src
README 文档
README
Single function to get wordpress attachment id from an img src, regardless of whether the img src is a resized thumbnail or the original image.
Usage
Installation
Via Composer
Neat_html is available on Packagist (perchten/wordpress_attachmentfromimg) and as such is installable via Composer.
Add the following to your composer.json
{
"require": {s
"perchten/wordpress_attachmentfromimg": "1.*"
}
}
Direct include
Clone or download from GitHub and include directly in your code:
require_once "path/to/neat_html.php"
Code
Basic usage to get the ID:
get_attachment_id_from_img_src($image_src)
If you want a specific thumbnail img src rather than just the ID, you can also use:
get_attachment_id_from_img_src($image_src,$thumb)
This will only work if the thumbnail size has been previously defined. It will NOT return the <img> tag, but just the src url. It will also not return the image metadata such as size. If you need that, then use the inbuilt Wordpress function wp_get_attachment_image_src() instead.
Why Not A Wordpress Plugin?
Because it's tiny and only useful for developers.
If you're a developer and unfamiliar with Composer, go check it out. You can use it to load utility libraries into your plugins or themes.
统计信息
- 总下载量: 26
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-05-26