2017 © Pedro Peláez
 

library wordpress_attachmentfromimg

Single function to get wordpress attachment id from an img src

image

perchten/wordpress_attachmentfromimg

Single function to get wordpress attachment id from an img src

  • Tuesday, May 27, 2014
  • by perchten
  • Repository
  • 1 Watchers
  • 0 Stars
  • 17 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

wordpressAttachmentIdFromImg

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., (*1)

Usage

Installation

Via Composer

Neat_html is available on Packagist (perchten/wordpress_attachmentfromimg) and as such is installable via Composer., (*2)

Add the following to your composer.json, (*3)

{
    "require": {s
        "perchten/wordpress_attachmentfromimg": "1.*"
    }
}
Direct include

Clone or download from GitHub and include directly in your code:, (*4)

require_once "path/to/neat_html.php"

Code

Basic usage to get the ID:, (*5)

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:, (*6)

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., (*7)

Why Not A Wordpress Plugin?

Because it's tiny and only useful for developers., (*8)

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., (*9)

The Versions

27/05 2014

dev-master

9999999-dev https://github.com/perchten/wordpressAttachmentFromImg

Single function to get wordpress attachment id from an img src

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

wordpress image util functional attachment

27/05 2014

1.0.4

1.0.4.0 https://github.com/perchten/wordpressAttachmentFromImg

Single function to get wordpress attachment id from an img src

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

wordpress image util functional attachment

27/05 2014

1.0.3

1.0.3.0 https://github.com/perchten/wordpressAttachmentFromImg

Single function to get wordpress attachment id from an img src

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

wordpress image util functional attachment

27/05 2014

1.0.0

1.0.0.0 https://github.com/perchten/wordpressAttachmentFromImg

Single function to get wordpress attachment id from an img src

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

wordpress image util functional attachment