WordPress.org

Make WordPress Core

Ticket #9036: media-links-upgrade.2.patch

File media-links-upgrade.2.patch, 4.1 KB (added by noel, 9 years ago)
  • wp-includes/post-template.php

     
    908908 * @uses apply_filters() Calls 'wp_get_attachment_link' filter on HTML content with same parameters as function.
    909909 *
    910910 * @param int $id Optional. Post ID.
    911  * @param string $size Optional. Image size.
     911 * @param string $size Optional, default is 'thumbnail'. Size of image, either array or string.
    912912 * @param bool $permalink Optional, default is false. Whether to add permalink to image.
    913913 * @param bool $icon Optional, default is false. Whether to include icon.
     914 * @param string $text Optional, default is false. If string, then will be link text.
    914915 * @return string HTML content.
    915916 */
    916 function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false, $icon = false) {
     917function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false) {
    917918        $id = intval($id);
    918919        $_post = & get_post( $id );
    919920
     
    924925                $url = get_attachment_link($_post->ID);
    925926
    926927        $post_title = attribute_escape($_post->post_title);
    927 
    928         $link_text = wp_get_attachment_image($id, $size, $icon);
    929         if ( !$link_text )
     928       
     929        if($text) {
     930                $link_text = attribute_escape($text);
     931        } elseif( ( is_int($size) && $size != 0 ) or ( is_string($size) && $size != 'none' ) or $size != false) {
     932                $link_text = wp_get_attachment_image($id, $size, $icon);
     933        } else {
    930934                $link_text = $_post->post_title;
    931 
     935        }
     936       
    932937        return apply_filters( 'wp_get_attachment_link', "<a href='$url' title='$post_title'>$link_text</a>", $id, $size, $permalink, $icon );
    933938}
    934939
     
    11911196        $autosavef = __( '%s [Autosave]' );
    11921197        $currentf  = __( '%s [Current Revision]' );
    11931198
    1194         $date = date_i18n( $datef, strtotime( $revision->post_modified ) );
     1199        $date = date_i18n( $datef, strtotime( $revision->post_modified_gmt . ' +0000' ) );
    11951200        if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) )
    11961201                $date = "<a href='$link'>$date</a>";
    11971202
  • wp-includes/media.php

     
    689689 * Display previous image link that has the same post parent.
    690690 *
    691691 * @since 2.5.0
     692 * @param string $size Optional, default is 'thumbnail'. Size of image, either array or string. 0 or 'none' will default to post_title or $text;
     693 * @param string $text Optional, default is false. If included, link will reflect $text variable.
     694 * @return string HTML content.
    692695 */
    693 function previous_image_link() {
    694         adjacent_image_link(true);
     696function previous_image_link($size = 'thumbnail', $text = false) {
     697        adjacent_image_link(true, $size, $text);
    695698}
    696699
    697700/**
    698701 * Display next image link that has the same post parent.
    699702 *
    700703 * @since 2.5.0
     704 * @param string $size Optional, default is 'thumbnail'. Size of image, either array or string. 0 or 'none' will default to post_title or $text;
     705 * @param string $text Optional, default is false. If included, link will reflect $text variable.
     706 * @return string HTML content.
    701707 */
    702 function next_image_link() {
    703         adjacent_image_link(false);
     708function next_image_link($size = 'thumbnail', $text = false) {
     709        adjacent_image_link(false, $size, $text);
    704710}
    705711
    706712/**
     
    712718 *
    713719 * @param bool $prev Optional. Default is true to display previous link, true for next.
    714720 */
    715 function adjacent_image_link($prev = true) {
     721function adjacent_image_link($prev = true, $size = 'thumbnail', $text = false) {
    716722        global $post;
    717723        $post = get_post($post);
    718724        $attachments = array_values(get_children( array('post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') ));
     
    724730        $k = $prev ? $k - 1 : $k + 1;
    725731
    726732        if ( isset($attachments[$k]) )
    727                 echo wp_get_attachment_link($attachments[$k]->ID, 'thumbnail', true);
     733                echo wp_get_attachment_link($attachments[$k]->ID, $size, true, false, $text);
    728734}
    729735
    730736/**