[ Index ]

PHP Cross Reference of Wordpress 2.9.1

title

Body

[close]

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

WordPress API for media display.

File Size: 1303 lines (44 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 1 file
 wp-includes/class-oembed.php

Defines 1 class

WP_Embed:: (18 methods):
  WP_Embed()
  __construct()
  run_shortcode()
  maybe_run_ajax_cache()
  register_handler()
  unregister_handler()
  shortcode()
  delete_oembed_caches()
  cache_oembed()
  autoembed()
  autoembed_callback()
  maybe_make_link()
  wp_embed_register_handler()
  wp_embed_unregister_handler()
  wp_embed_defaults()
  wp_expand_dimensions()
  wp_oembed_get()
  wp_oembed_add_provider()

Defines 18 functions

  image_constrain_size_for_editor()
  image_hwstring()
  image_downsize()
  add_image_size()
  set_post_thumbnail_size()
  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()
  _wp_post_thumbnail_class_filter()
  _wp_post_thumbnail_class_filter_add()
  _wp_post_thumbnail_class_filter_remove()
  img_caption_shortcode()
  gallery_shortcode()
  previous_image_link()
  next_image_link()
  adjacent_image_link()
  get_attachment_taxonomies()
  gd_edit_image_support()
  wp_imagecreatetruecolor()

Class: WP_Embed  - X-Ref

API for easily embedding rich media such as videos and images into content.

WP_Embed()   X-Ref
PHP4 constructor


__construct()   X-Ref
PHP5 constructor


run_shortcode( $content )   X-Ref
Process the [embed] shortcode.

Since the [embed] shortcode needs to be run earlier than other shortcodes,
this function removes all existing shortcodes, registers the [embed] shortcode,
calls {@link do_shortcode()}, and then re-registers the old shortcodes.

param: string $content Content to parse
return: string Content with shortcode parsed

maybe_run_ajax_cache()   X-Ref
If a post/page was saved, then output Javascript to make
an AJAX request that will call WP_Embed::cache_oembed().


register_handler( $id, $regex, $callback, $priority = 10 )   X-Ref
Register an embed handler. Do not use this function directly, use {@link wp_embed_register_handler()} instead.
This function should probably also only be used for sites that do not support oEmbed.

param: string $id An internal ID/name for the handler. Needs to be unique.
param: string $regex The regex that will be used to see if this handler should be used for a URL.
param: callback $callback The callback function that will be called if the regex is matched.
param: int $priority Optional. Used to specify the order in which the registered handlers will be tested (default: 10). Lower numbers correspond with earlier testing, and handlers with the same priority are tested in the order in which they were added to the action.

unregister_handler( $id, $priority = 10 )   X-Ref
Unregister a previously registered embed handler. Do not use this function directly, use {@link wp_embed_unregister_handler()} instead.

param: string $id The handler ID that should be removed.
param: int $priority Optional. The priority of the handler to be removed (default: 10).

shortcode( $attr, $url = '' )   X-Ref
The {@link do_shortcode()} callback function.

Attempts to convert a URL into embed HTML. Starts by checking the URL against the regex of the registered embed handlers.
If none of the regex matches and it's enabled, then the URL will be given to the {@link WP_oEmbed} class.

param: array $attr Shortcode attributes.
param: string $url The URL attempting to be embeded.
return: string The embed HTML on success, otherwise the original URL.

delete_oembed_caches( $post_ID )   X-Ref
Delete all oEmbed caches.

param: int $post_ID Post ID to delete the caches for.

cache_oembed( $post_ID )   X-Ref
Triggers a caching of all oEmbed results.

param: int $post_ID Post ID to do the caching for.

autoembed( $content )   X-Ref
Passes any unlinked URLs that are on their own line to {@link WP_Embed::shortcode()} for potential embedding.

param: string $content The content to be searched.
return: string Potentially modified $content.

autoembed_callback( $match )   X-Ref
Callback function for {@link WP_Embed::autoembed()}.

param: array $match A regex match array.
return: string The embed HTML on success, otherwise the original URL.

maybe_make_link( $url )   X-Ref
Conditionally makes a hyperlink based on an internal class variable.

param: string $url URL to potentially be linked.
return: string Linked URL or the original URL.

wp_embed_register_handler( $id, $regex, $callback, $priority = 10 )   X-Ref
Register an embed handler. This function should probably only be used for sites that do not support oEmbed.


wp_embed_unregister_handler( $id, $priority = 10 )   X-Ref
Unregister a previously registered embed handler.


wp_embed_defaults()   X-Ref
Create default array of embed parameters.

return: array Default embed parameters.

wp_expand_dimensions( $example_width, $example_height, $max_width, $max_height )   X-Ref
Based on a supplied width/height example, return the biggest possible dimensions based on the max width/height.

param: int $example_width The width of an example embed.
param: int $example_height The height of an example embed.
param: int $max_width The maximum allowed width.
param: int $max_height The maximum allowed height.
return: array The maximum possible width and height based on the example ratio.

wp_oembed_get( $url, $args = '' )   X-Ref
Attempts to fetch the embed HTML for a provided URL using oEmbed.

param: string $url The URL that should be embeded.
param: array $args Addtional arguments and parameters.
return: string The original URL on failure or the embed HTML on success.

wp_oembed_add_provider( $format, $provider, $regex = false )   X-Ref
Adds a URL format and oEmbed provider URL pair.

param: string $format The format of URL that this provider can handle. You can use asterisks as wildcards.
param: string $provider The URL to the oEmbed provider.
param: boolean $regex Whether the $format parameter is in a regex format or not.

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.

add_image_size( $name, $width = 0, $height = 0, $crop = FALSE )   X-Ref
Registers a new image size


set_post_thumbnail_size( $width = 0, $height = 0, $crop = FALSE )   X-Ref
Registers an image size for the post thumbnail


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, $attr = '')   X-Ref
Get an HTML img element representing an image 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.

_wp_post_thumbnail_class_filter( $attr )   X-Ref
Adds a 'wp-post-image' class to post thumbnail thumbnails
Uses the begin_fetch_post_thumbnail_html and end_fetch_post_thumbnail_html action hooks to
dynamically add/remove itself so as to only filter post thumbnail thumbnails

author: Mark Jaquith
param: array $attr Attributes including src, class, alt, title
return: array

_wp_post_thumbnail_class_filter_add( $attr )   X-Ref
Adds _wp_post_thumbnail_class_filter to the wp_get_attachment_image_attributes filter

author: Mark Jaquith

_wp_post_thumbnail_class_filter_remove( $attr )   X-Ref
Removes _wp_post_thumbnail_class_filter from the wp_get_attachment_image_attributes filter

author: Mark Jaquith

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($size = 'thumbnail', $text = false)   X-Ref
Display previous image link that has the same post parent.

param: string $size Optional, default is 'thumbnail'. Size of image, either array or string. 0 or 'none' will default to post_title or $text;
param: string $text Optional, default is false. If included, link will reflect $text variable.
return: string HTML content.

next_image_link($size = 'thumbnail', $text = false)   X-Ref
Display next image link that has the same post parent.

param: string $size Optional, default is 'thumbnail'. Size of image, either array or string. 0 or 'none' will default to post_title or $text;
param: string $text Optional, default is false. If included, link will reflect $text variable.
return: string HTML content.

adjacent_image_link($prev = true, $size = 'thumbnail', $text = false)   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.

gd_edit_image_support($mime_type)   X-Ref
Check if the installed version of GD supports particular image type

param: $mime_type string
return: bool

wp_imagecreatetruecolor($width, $height)   X-Ref
Create new GD image resource with transparency support

param: $width
param: $height
return: image resource



Generated: Fri Jan 8 00:19:48 2010 Cross-referenced by PHPXref 0.7