public static
array
|
#
find_ids_like_slug( string $slug_like = null, boolean $mime_type = 'image', integer $num_ids_desired = 0 )
Returns an array of all attachment IDs present in the media library that
match a given slug pattern.
Returns an array of all attachment IDs present in the media library that
match a given slug pattern.
Parameters
- $slug_like
string $slug_like Search for attachments that match this name; can use SQL 'like'
wildcards
- $mime_type
boolean $mime_type Can be something like 'image' to find 'image/png', 'image/jpg', etc;
or null for everything
- $num_ids_desired
integer $num_ids_desired The first X rows will be returned; otherwise use 0 for
everything
Returns
array If found, an array of attachment IDs; otherwise, null
|
public static
array
|
#
find_first_id_like_slug( string $slug_like = null, boolean $mime_type = 'image' )
Returns the first-found attachment ID present in the media library that
matches a given slug pattern.
Returns the first-found attachment ID present in the media library that
matches a given slug pattern.
Parameters
- $slug_like
string $slug_like Search for attachments that match this name; can use SQL 'like'
wildcards
- $mime_type
boolean $mime_type Can be something like 'image' to find 'image/png', 'image/jpg', etc;
or null for everything
Returns
array If found, a single attachment ID; otherwise, null
|
public static
array
|
#
find_image_ids_like_slug( string $slug_like = null, integer $num_ids_desired = 0 )
Returns an array of all image IDs present in the media library that match the
given slug pattern.
Returns an array of all image IDs present in the media library that match the
given slug pattern.
Parameters
- $slug_like
string $slug_like Search for images that match this name; can use SQL 'like' wildcards
- $num_ids_desired
integer $num_ids_desired The first X rows will be returned; otherwise use 0 for
everything
Returns
array If found, an array of image IDs; otherwise, null
|
public static
array
|
#
find_first_image_id_like_slug( string $slug_like = null )
Returns the first-found image ID present in the media library that matches a
given slug pattern.
Returns the first-found image ID present in the media library that matches a
given slug pattern.
Parameters
- $slug_like
string $slug_like Search for an image that matches this name; can use SQL 'like'
wildcards
Returns
array If found, a single image ID; otherwise, null
|
public static
array
|
#
get_meta_info( integer $attachment_id, boolean $include_sizes = false )
Retrieves information on an attachment. Oddly, no native function exists in
WordPress to give this kind of info all-in-one.
Retrieves information on an attachment. Oddly, no native function exists in
WordPress to give this kind of info all-in-one.
Parameters
- $attachment_id
integer $attachment_id The ID of the attachment whose info is desired
- $include_sizes
boolean $include_sizes Set to 'true' and the returned array will contain an embedded
array with the 'src' for each image size
Returns
array This array contains 'alt', 'caption', 'description', 'href', 'src', and 'title'
(and optionally, 'sizes')
|
public static
strubg
|
#
generate_resized_image_html_by_original_path( string $path, string $size = 'full', string $title = '', string $class = '' )
Return the sized-specific HTML for a full path image. Specifically, if you
send it something like 'http://www.mysite.com/stuff.png' and you ask for the
'medium' registered WP side, you might get something back like
'http://www.mysite.com/stuff-300x300.png'.
Return the sized-specific HTML for a full path image. Specifically, if you
send it something like 'http://www.mysite.com/stuff.png' and you ask for the
'medium' registered WP side, you might get something back like
'http://www.mysite.com/stuff-300x300.png'.
Parameters
- $path
string $path The full path of the image desired
- $size
string $size A thumbnail slug; can be 'medium', 'thumbnail', etc; defaults to 'full'
- $title
string $title An optional attribute to be used in the generated HTML
- $class
string $class An optional class to apply to the generated HTML
Returns
strubg The generated resized image markup
|
public static
strubg
|
#
generate_image_html_by_id( integer $id, string $size = 'full', string $title = '', string $class = '' )
Return the HTML for an image ID. WordPress already offers this kind of
functionality, but it is being added here to pair up with the sibling function -
generate_image_html_by_slug.
Return the HTML for an image ID. WordPress already offers this kind of
functionality, but it is being added here to pair up with the sibling function -
generate_image_html_by_slug.
Parameters
- $id
integer $id The ID of the image desired
- $size
string $size A thumbnail slug; can be 'medium', 'thumbnail', etc; defaults to 'full'
- $title
string $title An optional attribute to be used in the generated HTML
- $class
string $class An optional class to apply to the generated HTML
Returns
strubg The generated image markup
|
public static
strubg
|
#
generate_image_html_by_slug( string $slug, string $size = 'full', string $title = '', string $class = '' )
Return the HTML for an image slug. Oddly, WordPress only offers this kind of
functionality against an ID, not a slug.
Return the HTML for an image slug. Oddly, WordPress only offers this kind of
functionality against an ID, not a slug.
Parameters
- $slug
string $slug The name of the image desired; can use SQL 'like' wildcards
- $size
string $size A thumbnail slug; can be 'medium', 'thumbnail', etc; defaults to 'full'
- $title
string $title An optional attribute to be used in the generated HTML
- $class
string $class An optional class to apply to the generated HTML
Returns
strubg The generated image markup
|
public static
array
|
#
get_image_sizes( boolean $include_dimensions = false )
Returns a list of image sizes registered in the active WP database.
Returns a list of image sizes registered in the active WP database.
Parameters
- $include_dimensions
boolean $include_dimensions If set to 'true', an element in the list might look like
this: 'medium 300x300'
Returns
array A list of sizes as string (e.g. 'thumbnail', 'medium', 'full', etc)
Link
|
public static
string
|
#
get_attachment_alt_text( integer $attachment_id )
Attachments can have 'alternative text' specified by the user. Unfortunately,
this value does not live in the attachment/post object - instead, it is stored
as a custom field and the key is not so obvious. Thus, this accessor.
Attachments can have 'alternative text' specified by the user. Unfortunately,
this value does not live in the attachment/post object - instead, it is stored
as a custom field and the key is not so obvious. Thus, this accessor.
Parameters
- $attachment_id
integer $attachment_id The ID of the attachment whose alt text is sought
Returns
string The alt text, if found; otherwise, an empty string
Link
|