Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #32072, comment 1


Ignore:
Timestamp:
04/23/2015 12:13:31 AM (11 years ago)
Author:
tychay
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #32072, comment 1

    initial v1  
    22
    33{{{#!php
    4 $rel = ( $url ) ? ' rel="attachment wp-att-' . $id . '"' : '';
     4<?php
     5$rel = ('…') ? ' rel="attachment wp-att-' . $id . '"' : '';
    56}}}
    67
    78Else it will trigger a warning in the {{{'image'}}} code.
     9
     10e.g.
     11{{{#!php
     12<?php
     13        $url = ( empty ($attachment['url'] ) ) ? '' : $attachment['url'];
     14        $rel = ( strpos( $url, 'attachment_id') || get_attachment_link( $id ) == $url ) ?  ' rel="attachment wp-att-' . $id . '"' : '';
     15
     16        remove_filter( 'media_send_to_editor', 'image_media_send_to_editor' );
     17
     18        if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) {
     19                $align = isset( $attachment['align'] ) ? $attachment['align'] : 'none';
     20                $size = isset( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium';
     21                $alt = isset( $attachment['image_alt'] ) ? $attachment['image_alt'] : '';
     22                $caption = isset( $attachment['post_excerpt'] ) ? $attachment['post_excerpt'] : '';
     23                $title = ''; // We no longer insert title tags into <img> tags, as they are redundant.
     24                $html = get_image_send_to_editor( $id, $caption, $title, $align, $url, (bool) $rel, $size, $alt );
     25        } elseif ( 'video' === substr( $post->post_mime_type, 0, 5 ) || 'audio' === substr( $post->post_mime_type, 0, 5 )  ) {
     26                $html = stripslashes_deep( $_POST['html'] );
     27        } else {
     28                $html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : '';
     29                if ( $url ) {
     30                        $html = '<a href="' . esc_url( $url ) . '"' . $rel . '>' . $html . '</a>';
     31                }
     32        }
     33}}}