[ Index ]

WordPress Cross Reference

title

Body

[close]

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

WordPress API for media display.

File Size: 2092 lines (71 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 5 files
 wp-includes/media-template.php
 wp-includes/class-wp-image-editor-imagick.php
 wp-includes/class-oembed.php
 wp-includes/class-wp-image-editor-gd.php
 wp-includes/class-wp-image-editor.php

Defines 54 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_make_intermediate_size()
  image_get_intermediate_size()
  get_intermediate_image_sizes()
  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()
  wp_mediaelement_fallback()
  wp_get_audio_extensions()
  wp_audio_shortcode()
  wp_get_video_extensions()
  wp_video_shortcode()
  previous_image_link()
  next_image_link()
  adjacent_image_link()
  get_attachment_taxonomies()
  get_taxonomies_for_attachments()
  wp_imagecreatetruecolor()
  wp_embed_register_handler()
  wp_embed_unregister_handler()
  wp_embed_defaults()
  wp_expand_dimensions()
  wp_oembed_get()
  wp_oembed_add_provider()
  wp_oembed_remove_provider()
  wp_maybe_load_embeds()
  wp_embed_handler_googlevideo()
  wp_embed_handler_audio()
  wp_embed_handler_video()
  wp_convert_hr_to_bytes()
  wp_max_upload_size()
  wp_get_image_editor()
  wp_image_editor_supports()
  _wp_image_editor_choose()
  wp_plupload_default_settings()
  wp_prepare_attachment_for_js()
  wp_enqueue_media()
  get_attached_media()
  get_media_embedded_in_content()
  get_post_galleries()
  get_post_gallery()
  get_post_galleries_images()
  get_post_gallery_images()

Functions
Functions that are not part of a class:

image_constrain_size_for_editor($width, $height, $size = 'medium', $context = null )   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.
param: context Could be 'display' (like in a theme) or 'edit' (like inserting into an editor)
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: array|string $size Optional, default is 'medium'. Size of image, either array or string.
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 dimensions for a downsampled image.

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 WP_Image_Editor.

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_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.

If you are passing an array for the $size, you should consider using
add_image_size() so that a cropped version is generated. It's much more
efficient than having to find the closest-sized image and then having the
browser scale down the image.

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.

get_intermediate_image_sizes()   X-Ref
Get the available image sizes

return: array Returns a filtered array of image size strings

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

While $size will accept an array, it is better to register a size with
add_image_size() so that a cropped version is generated. It's much more
efficient than having to find the closest-sized image and then having the
browser scale down the image.

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.
param: mixed $attr Optional, attributes for the image markup.
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 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 thumbnails

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


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


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 of the shortcode.
return: string HTML content to display gallery.

wp_mediaelement_fallback( $url )   X-Ref
Provide a No-JS Flash fallback as a last resort for audio / video

param: string $url
return: string Fallback HTML

wp_get_audio_extensions()   X-Ref
Return a filtered list of WP-supported audio formats

return: array

wp_audio_shortcode( $attr, $content = '' )   X-Ref
The Audio shortcode.

This implements the functionality of the Audio Shortcode for displaying
WordPress mp3s in a post.

param: array  $attr    Attributes of the shortcode.
param: string $content Optional. Shortcode content.
return: string HTML content to display audio.

wp_get_video_extensions()   X-Ref
Return a filtered list of WP-supported video formats

return: array

wp_video_shortcode( $attr, $content = '' )   X-Ref
The Video shortcode.

This implements the functionality of the Video Shortcode for displaying
WordPress mp4s in a post.

param: array  $attr    Attributes of the shortcode.
param: string $content Optional. Shortcode content.
return: string HTML content to display video.

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, false 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.

get_taxonomies_for_attachments( $output = 'names' )   X-Ref
Return all of the taxonomy names that are registered for attachments.

Handles mime-type-specific taxonomies such as attachment:image and attachment:video.

param: string $output The type of output to return, either taxonomy 'names' or 'objects'. 'names' is the default.
return: array The names of all taxonomy of $object_type.

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

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

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.

The width defaults to the content width as specified by the theme. If the
theme does not specify a content width, then 500px is used.

The default height is 1.5 times the width, or 1000px, whichever is smaller.

The 'embed_defaults' filter can be used to adjust either of these values.

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 embedded.
param: array $args Additional arguments and parameters.
return: bool|string False 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.

wp_oembed_remove_provider( $format )   X-Ref
Removes an oEmbed provider.

param: string $format The URL format for the oEmbed provider to remove.

wp_maybe_load_embeds()   X-Ref
Determines if default embed handlers should be loaded.

Checks to make sure that the embeds library hasn't already been loaded. If
it hasn't, then it will load the embeds library.


wp_embed_handler_googlevideo( $matches, $attr, $url, $rawattr )   X-Ref
The Google Video embed handler callback. Google Video does not support oEmbed.

param: array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}.
param: array $attr Embed attributes.
param: string $url The original URL that was matched by the regex.
param: array $rawattr The original unmodified attributes.
return: string The embed HTML.

wp_embed_handler_audio( $matches, $attr, $url, $rawattr )   X-Ref
Audio embed handler callback.

param: array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}.
param: array $attr Embed attributes.
param: string $url The original URL that was matched by the regex.
param: array $rawattr The original unmodified attributes.
return: string The embed HTML.

wp_embed_handler_video( $matches, $attr, $url, $rawattr )   X-Ref
Video embed handler callback.

param: array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}.
param: array $attr Embed attributes.
param: string $url The original URL that was matched by the regex.
param: array $rawattr The original unmodified attributes.
return: string The embed HTML.

wp_convert_hr_to_bytes( $size )   X-Ref
Converts a shorthand byte value to an integer byte value.

param: string $size A shorthand byte value.
return: int An integer byte value.

wp_max_upload_size()   X-Ref
Determine the maximum upload size allowed in php.ini.

return: int Allowed upload size.

wp_get_image_editor( $path, $args = array()   X-Ref
Returns a WP_Image_Editor instance and loads file into it.

param: string $path Path to file to load
param: array $args Additional data. Accepts { 'mime_type'=>string, 'methods'=>{string, string, ...} }
return: WP_Image_Editor|WP_Error

wp_image_editor_supports( $args = array()   X-Ref
Tests whether there is an editor that supports a given mime type or methods.

param: string|array $args Array of requirements. Accepts { 'mime_type'=>string, 'methods'=>{string, string, ...} }
return: boolean true if an eligible editor is found; false otherwise

_wp_image_editor_choose( $args = array()   X-Ref
Tests which editors are capable of supporting the request.

param: array $args Additional data. Accepts { 'mime_type'=>string, 'methods'=>{string, string, ...} }
return: string|bool Class name for the first editor that claims to support the request. False if no editor claims to support the request.

wp_plupload_default_settings()   X-Ref
Prints default plupload arguments.


wp_prepare_attachment_for_js( $attachment )   X-Ref
Prepares an attachment post object for JS, where it is expected
to be JSON-encoded and fit into an Attachment model.

param: mixed $attachment Attachment ID or object.
return: array Array of attachment details.

wp_enqueue_media( $args = array()   X-Ref
Enqueues all scripts, styles, settings, and templates necessary to use
all media JS APIs.


get_attached_media( $type, $post = 0 )   X-Ref
Retrieve media attached to the passed post

param: string $type (Mime) type of media desired
param: mixed $post Post ID or object
return: array Found attachments

get_media_embedded_in_content( $content, $types = null )   X-Ref
Check the content blob for an <audio>, <video> <object>, <embed>, or <iframe>

param: string $content A string which might contain media data.
param: array $types array of media types: 'audio', 'video', 'object', 'embed', or 'iframe'
return: array A list of found HTML media embeds

get_post_galleries( $post, $html = true )   X-Ref
Retrieve galleries from the passed post's content

param: mixed $post Optional. Post ID or object.
param: boolean $html Whether to return HTML or data in the array
return: array A list of arrays, each containing gallery data and srcs parsed

get_post_gallery( $post = 0, $html = true )   X-Ref
Check a specified post's content for gallery and, if present, return the first

param: mixed $post Optional. Post ID or object.
param: boolean $html Whether to return HTML or data
return: string|array Gallery data and srcs parsed from the expanded shortcode

get_post_galleries_images( $post = 0 )   X-Ref
Retrieve the image srcs from galleries from a post's content, if present

param: mixed $post Optional. Post ID or object.
return: array A list of lists, each containing image srcs parsed

get_post_gallery_images( $post = 0 )   X-Ref
Check a post's content for galleries and return the image srcs for the first found gallery

param: mixed $post Optional. Post ID or object.
return: array A list of a gallery's image srcs in order



Generated: Tue Mar 25 01:41:18 2014 WordPress honlapkészítés: online1.hu