WordPress.org

Make WordPress Core

Changeset 8792


Ignore:
Timestamp:
09/01/2008 05:45:41 AM (10 years ago)
Author:
ryan
Message:

phpdoc for media.php. Props jacobsantos. see #7658

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/media.php

    r8612 r8792  
    11<?php
    2 
    3 // functions for media display
    4 
    5 // scale down the default size of an image so it's a better fit for the editor and theme
     2/**
     3 * WordPress API for media display.
     4 *
     5 * @package WordPress
     6 */
     7
     8/**
     9 * Scale down the default size of an image.
     10 *
     11 * This is so that the image is a better fit for the editor and theme.
     12 *
     13 * The $size parameter accepts either an array or a string. The supported string
     14 * values are 'thumb' or 'thumbnail' for the given thumbnail size or defaults at
     15 * 128 width and 96 height in pixels. Also supported for the string value is
     16 * 'medium' and 'full'. The 'full' isn't actually supported, but any value other
     17 * than the supported will result in the content_width size or 500 if that is
     18 * not set.
     19 *
     20 * Finally, there is a filter named, 'editor_max_image_size' that will be called
     21 * on the calculated array for width and height, respectively. The second
     22 * parameter will be the value that was in the $size parameter. The returned
     23 * type for the hook is an array with the width as the first element and the
     24 * height as the second element.
     25 *
     26 * @since 2.5.0
     27 * @uses wp_constrain_dimensions() This function passes the widths and the heights.
     28 *
     29 * @param int $width Width of the image
     30 * @param int $height Height of the image
     31 * @param string|array $size Size of what the result image should be.
     32 * @return array Width and height of what the result image should resize to.
     33 */
    634function image_constrain_size_for_editor($width, $height, $size = 'medium') {
    735    global $content_width;
     
    4573}
    4674
    47 // return a width/height string for use in an <img /> tag.  Empty values will be omitted.
     75/**
     76 * Retrieve width and height attributes using given width and height values.
     77 *
     78 * Both attributes are required in the sense that both parameters must have a
     79 * value, but are optional in that if you set them to false or null, then they
     80 * will not be added to the returned string.
     81 *
     82 * You can set the value using a string, but it will only take numeric values.
     83 * If you wish to put 'px' after the numbers, then it will be stripped out of
     84 * the return.
     85 *
     86 * @since 2.5.0
     87 *
     88 * @param int|string $width Optional. Width attribute value.
     89 * @param int|string $height Optional. Height attribute value.
     90 * @return string HTML attributes for width and, or height.
     91 */
    4892function image_hwstring($width, $height) {
    4993    $out = '';
     
    5599}
    56100
    57 // Scale an image to fit a particular size (such as 'thumb' or 'medium'), and return an image URL, height and width.
    58 // 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.
    59 // returns an array($url, $width, $height, $is_intermediate)
    60 // $is_intermediate is true if $url is a resized image, false if it is the original
     101/**
     102 * Scale an image to fit a particular size (such as 'thumb' or 'medium').
     103 *
     104 * Array with image url, width, height, and whether is intermediate size, in
     105 * that order is returned on success is returned. $is_intermediate is true if
     106 * $url is a resized image, false if it is the original.
     107 *
     108 * The URL might be the original image, or it might be a resized version. This
     109 * function won't create a new resized copy, it will just return an already
     110 * resized one if it exists.
     111 *
     112 * @since 2.5.0
     113 * @uses apply_filters() Calls 'image_downsize' on $id and $size to provide
     114 *      resize services. Should return true if resizes.
     115 *
     116 * @param int $id Attachment ID for image.
     117 * @param string $size Optional, default is 'medium'. Size of image, can be 'thumbnail'.
     118 * @return bool|array False on failure, array on success.
     119 */
    61120function image_downsize($id, $size = 'medium') {
    62121
     
    110169 * {@internal Missing Long Description}}
    111170 *
     171 * @since 2.5.0
     172 *
    112173 * @uses apply_filters() The 'get_image_tag_class' filter is the IMG element
    113174 *      class attribute.
     
    208269}
    209270
    210 // Scale down an image to fit a particular size and save a new copy of the image
     271/**
     272 * Scale down an image to fit a particular size and save a new copy of the image.
     273 *
     274 * @param unknown_type $file
     275 * @param unknown_type $max_w
     276 * @param unknown_type $max_h
     277 * @param unknown_type $crop
     278 * @param unknown_type $suffix
     279 * @param unknown_type $dest_path
     280 * @param unknown_type $jpeg_quality
     281 * @return unknown
     282 */
    211283function image_resize( $file, $max_w, $max_h, $crop=false, $suffix=null, $dest_path=null, $jpeg_quality=90) {
    212284
     
    483555}
    484556
     557/**
     558 * Display previous image link that has the same post parent.
     559 *
     560 * @since 2.5.0
     561 */
    485562function previous_image_link() {
    486563    adjacent_image_link(true);
    487564}
    488565
     566/**
     567 * Display next image link that has the same post parent.
     568 *
     569 * @since 2.5.0
     570 */
    489571function next_image_link() {
    490572    adjacent_image_link(false);
    491573}
    492574
     575/**
     576 * Display next or previous image link that has the same post parent.
     577 *
     578 * Retrieves the current attachment object from the $post global.
     579 *
     580 * @since 2.5.0
     581 *
     582 * @param bool $prev Optional. Default is true to display previous link, true for next.
     583 */
    493584function adjacent_image_link($prev = true) {
    494585    global $post;
Note: See TracChangeset for help on using the changeset viewer.