[ Index ]

PHP Cross Reference of Wordpress 2.7.1

title

Body

[close]

/wp-includes/ -> media.php (summary)

WordPress API for media display.

File Size: 769 lines (26 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 17 functions

  image_constrain_size_for_editor()
  image_hwstring()
  image_downsize()
  get_image_tag()
  wp_constrain_dimensions()
  image_resize_dimensions()
  image_resize()
  image_make_intermediate_size()
  image_get_intermediate_size()
  wp_get_attachment_image_src()
  wp_get_attachment_image()
  img_caption_shortcode()
  gallery_shortcode()
  previous_image_link()
  next_image_link()
  adjacent_image_link()
  get_attachment_taxonomies()

Functions
Functions that are not part of a class:

image_constrain_size_for_editor($width, $height, $size = 'medium')   X-Ref
Scale down the default size of an image.

This is so that the image is a better fit for the editor and theme.

The $size parameter accepts either an array or a string. The supported string
values are 'thumb' or 'thumbnail' for the given thumbnail size or defaults at
128 width and 96 height in pixels. Also supported for the string value is
'medium' and 'full'. The 'full' isn't actually supported, but any value other
than the supported will result in the content_width size or 500 if that is
not set.

Finally, there is a filter named, 'editor_max_image_size' that will be called
on the calculated array for width and height, respectively. The second
parameter will be the value that was in the $size parameter. The returned
type for the hook is an array with the width as the first element and the
height as the second element.

param: int $width Width of the image
param: int $height Height of the image
param: string|array $size Size of what the result image should be.
return: array Width and height of what the result image should resize to.

image_hwstring($width, $height)   X-Ref
Retrieve width and height attributes using given width and height values.

Both attributes are required in the sense that both parameters must have a
value, but are optional in that if you set them to false or null, then they
will not be added to the returned string.

You can set the value using a string, but it will only take numeric values.
If you wish to put 'px' after the numbers, then it will be stripped out of
the return.

param: int|string $width Optional. Width attribute value.
param: int|string $height Optional. Height attribute value.
return: string HTML attributes for width and, or height.

image_downsize($id, $size = 'medium')   X-Ref
Scale an image to fit a particular size (such as 'thumb' or 'medium').

Array with image url, width, height, and whether is intermediate size, in
that order is returned on success is returned. $is_intermediate is true if
$url is a resized image, false if it is the original.

The URL might be the original image, or it might be a resized version. This
function won't create a new resized copy, it will just return an already
resized one if it exists.

A plugin may use the 'image_downsize' filter to hook into and offer image
resizing services for images. The hook must return an array with the same
elements that are returned in the function. The first element being the URL
to the new image that was resized.

param: int $id Attachment ID for image.
param: string $size Optional, default is 'medium'. Size of image, can be 'thumbnail'.
return: bool|array False on failure, array on success.

get_image_tag($id, $alt, $title, $align, $size='medium')   X-Ref
An <img src /> tag for an image attachment, scaling it down if requested.

The filter 'get_image_tag_class' allows for changing the class name for the
image without having to use regular expressions on the HTML content. The
parameters are: what WordPress will use for the class, the Attachment ID,
image align value, and the size the image should be.

The second filter 'get_image_tag' has the HTML content, which can then be
further manipulated by a plugin to change all attribute values and even HTML
content.

param: int $id Attachment ID.
param: string $alt Image Description for the alt attribute.
param: string $title Image Description for the title attribute.
param: string $align Part of the class name for aligning the image.
param: string $size Optional. Default is 'medium'.
return: string HTML IMG element for given image attachment

wp_constrain_dimensions( $current_width, $current_height, $max_width=0, $max_height=0 )   X-Ref
Calculates the new dimentions for a downsampled image.

Same as {@link wp_shrink_dimensions()}, except the max parameters are
optional. If either width or height are empty, no constraint is applied on
that dimension.

param: int $current_width Current width of the image.
param: int $current_height Current height of the image.
param: int $max_width Optional. Maximum wanted width.
param: int $max_height Optional. Maximum wanted height.
return: array First item is the width, the second item is the height.

image_resize_dimensions($orig_w, $orig_h, $dest_w, $dest_h, $crop=false)   X-Ref
Retrieve calculated resized dimensions for use in imagecopyresampled().

Calculate dimensions and coordinates for a resized image that fits within a
specified width and height. If $crop is true, the largest matching central
portion of the image will be cropped out and resized to the required size.

param: int $orig_w Original width.
param: int $orig_h Original height.
param: int $dest_w New width.
param: int $dest_h New height.
param: bool $crop Optional, default is false. Whether to crop image or resize.
return: bool|array False, on failure. Returned array matches parameters for imagecopyresampled() PHP function.

image_resize( $file, $max_w, $max_h, $crop=false, $suffix=null, $dest_path=null, $jpeg_quality=90)   X-Ref
Scale down an image to fit a particular size and save a new copy of the image.

The PNG transparency will be preserved using the function, as well as the
image type. If the file going in is PNG, then the resized image is going to
be PNG. The only supported image types are PNG, GIF, and JPEG.

Some functionality requires API to exist, so some PHP version may lose out
support. This is not the fault of WordPress (where functionality is
downgraded, not actual defects), but of your PHP version.

param: string $file Image file path.
param: int $max_w Maximum width to resize to.
param: int $max_h Maximum height to resize to.
param: bool $crop Optional. Whether to crop image or resize.
param: string $suffix Optional. File Suffix.
param: string $dest_path Optional. New image file path.
param: int $jpeg_quality Optional, default is 90. Image quality percentage.
return: mixed WP_Error on failure. String with new destination path. Array of dimensions from {@link image_resize_dimensions()}

image_make_intermediate_size($file, $width, $height, $crop=false)   X-Ref
Resize an image to make a thumbnail or intermediate size.

The returned array has the file size, the image width, and image height. The
filter 'image_make_intermediate_size' can be used to hook in and change the
values of the returned array. The only parameter is the resized file path.

param: string $file File path.
param: int $width Image width.
param: int $height Image height.
param: bool $crop Optional, default is false. Whether to crop image to specified height and width or resize.
return: bool|array False, if no image was created. Metadata array on success.

image_get_intermediate_size($post_id, $size='thumbnail')   X-Ref
Retrieve the image's intermediate size (resized) path, width, and height.

The $size parameter can be an array with the width and height respectively.
If the size matches the 'sizes' metadata array for width and height, then it
will be used. If there is no direct match, then the nearest image size larger
than the specified size will be used. If nothing is found, then the function
will break out and return false.

The metadata 'sizes' is used for compatible sizes that can be used for the
parameter $size value.

The url path will be given, when the $size parameter is a string.

param: int $post_id Attachment ID for image.
param: array|string $size Optional, default is 'thumbnail'. Size of image, either array or string.
return: bool|array False on failure or array of file path, width, and height on success.

wp_get_attachment_image_src($attachment_id, $size='thumbnail', $icon = false)   X-Ref
Retrieve an image to represent an attachment.

A mime icon for files, thumbnail or intermediate size for images.

param: int $attachment_id Image attachment ID.
param: string $size Optional, default is 'thumbnail'.
param: bool $icon Optional, default is false. Whether it is an icon.
return: bool|array Returns an array (url, width, height), or false, if no image is available.

wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = false)   X-Ref
Retrieve img HTML content for an image to represent an attachment.

param: int $attachment_id Image attachment ID.
param: string $size Optional, default is 'thumbnail'.
param: bool $icon Optional, default is false. Whether it is an icon.
return: string HTML img element or empty string on failure.

img_caption_shortcode($attr, $content = null)   X-Ref
The Caption shortcode.

Allows a plugin to replace the content that would otherwise be returned. The
filter is 'img_caption_shortcode' and passes an empty string, the attr
parameter and the content parameter values.

The supported attributes for the shortcode are 'id', 'align', 'width', and
'caption'.

param: array $attr Attributes attributed to the shortcode.
param: string $content Optional. Shortcode content.
return: string

gallery_shortcode($attr)   X-Ref
The Gallery shortcode.

This implements the functionality of the Gallery Shortcode for displaying
WordPress images on a post.

param: array $attr Attributes attributed to the shortcode.
return: string HTML content to display gallery.

previous_image_link()   X-Ref
Display previous image link that has the same post parent.


next_image_link()   X-Ref
Display next image link that has the same post parent.


adjacent_image_link($prev = true)   X-Ref
Display next or previous image link that has the same post parent.

Retrieves the current attachment object from the $post global.

param: bool $prev Optional. Default is true to display previous link, true for next.

get_attachment_taxonomies($attachment)   X-Ref
Retrieve taxonomies attached to the attachment.

param: int|array|object $attachment Attachment ID, Attachment data array, or Attachment data object.
return: array Empty array on failure. List of taxonomies on success.



Generated: Mon Mar 23 16:23:02 2009 Cross-referenced by PHPXref 0.7