perchten/wordpress_attachmentfromimg 问题修复 & 功能扩展

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

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

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-05-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固