image_media_send_to_editor

The timeline below displays how wordpress function image_media_send_to_editor has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * Retrieves the media element HTML to send to the editor.
 *
 * @since 2.5.0
 *
 * @param string  $html
 * @param int     $attachment_id
 * @param array   $attachment
 * @return string
 */
function image_media_send_to_editor($html, $attachment_id, $attachment)
{
    $post = get_post($attachment_id);
    if (str_starts_with($post->post_mime_type, 'image')) {
        $url = $attachment['url'];
        $align = (!empty($attachment['align'])) ? $attachment['align'] : 'none';
        $size = (!empty($attachment['image-size'])) ? $attachment['image-size'] : 'medium';
        $alt = (!empty($attachment['image_alt'])) ? $attachment['image_alt'] : '';
        $rel = str_contains($url, 'attachment_id') || get_attachment_link($attachment_id) === $url;
        return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size, $alt);
    }
    return $html;
}

WordPress Version: 5.6

/**
 * Retrieves the media element HTML to send to the editor.
 *
 * @since 2.5.0
 *
 * @param string  $html
 * @param int     $attachment_id
 * @param array   $attachment
 * @return string
 */
function image_media_send_to_editor($html, $attachment_id, $attachment)
{
    $post = get_post($attachment_id);
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        $url = $attachment['url'];
        $align = (!empty($attachment['align'])) ? $attachment['align'] : 'none';
        $size = (!empty($attachment['image-size'])) ? $attachment['image-size'] : 'medium';
        $alt = (!empty($attachment['image_alt'])) ? $attachment['image_alt'] : '';
        $rel = strpos($url, 'attachment_id') || get_attachment_link($attachment_id) === $url;
        return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size, $alt);
    }
    return $html;
}

WordPress Version: 5.5

/**
 * Retrieves the media element HTML to send to the editor.
 *
 * @since 2.5.0
 *
 * @param string  $html
 * @param integer $attachment_id
 * @param array   $attachment
 * @return string
 */
function image_media_send_to_editor($html, $attachment_id, $attachment)
{
    $post = get_post($attachment_id);
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        $url = $attachment['url'];
        $align = (!empty($attachment['align'])) ? $attachment['align'] : 'none';
        $size = (!empty($attachment['image-size'])) ? $attachment['image-size'] : 'medium';
        $alt = (!empty($attachment['image_alt'])) ? $attachment['image_alt'] : '';
        $rel = strpos($url, 'attachment_id') || get_attachment_link($attachment_id) === $url;
        return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size, $alt);
    }
    return $html;
}

WordPress Version: 5.4

/**
 * Retrieves the media element HTML to send to the editor.
 *
 * @since 2.5.0
 *
 * @param string $html
 * @param integer $attachment_id
 * @param array $attachment
 * @return string
 */
function image_media_send_to_editor($html, $attachment_id, $attachment)
{
    $post = get_post($attachment_id);
    if (substr($post->post_mime_type, 0, 5) == 'image') {
        $url = $attachment['url'];
        $align = (!empty($attachment['align'])) ? $attachment['align'] : 'none';
        $size = (!empty($attachment['image-size'])) ? $attachment['image-size'] : 'medium';
        $alt = (!empty($attachment['image_alt'])) ? $attachment['image_alt'] : '';
        $rel = strpos($url, 'attachment_id') || get_attachment_link($attachment_id) === $url;
        return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size, $alt);
    }
    return $html;
}

WordPress Version: 4.5

/**
 * Retrieves the media element HTML to send to the editor.
 *
 * @since 2.5.0
 *
 * @param string $html
 * @param integer $attachment_id
 * @param array $attachment
 * @return string
 */
function image_media_send_to_editor($html, $attachment_id, $attachment)
{
    $post = get_post($attachment_id);
    if (substr($post->post_mime_type, 0, 5) == 'image') {
        $url = $attachment['url'];
        $align = (!empty($attachment['align'])) ? $attachment['align'] : 'none';
        $size = (!empty($attachment['image-size'])) ? $attachment['image-size'] : 'medium';
        $alt = (!empty($attachment['image_alt'])) ? $attachment['image_alt'] : '';
        $rel = strpos($url, 'attachment_id') || $url === get_attachment_link($attachment_id);
        return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size, $alt);
    }
    return $html;
}

WordPress Version: 4.4

/**
 * Retrieves the media element HTML to send to the editor.
 *
 * @since 2.5.0
 *
 * @param string $html
 * @param integer $attachment_id
 * @param array $attachment
 * @return string
 */
function image_media_send_to_editor($html, $attachment_id, $attachment)
{
    $post = get_post($attachment_id);
    if (substr($post->post_mime_type, 0, 5) == 'image') {
        $url = $attachment['url'];
        $align = (!empty($attachment['align'])) ? $attachment['align'] : 'none';
        $size = (!empty($attachment['image-size'])) ? $attachment['image-size'] : 'medium';
        $alt = (!empty($attachment['image_alt'])) ? $attachment['image_alt'] : '';
        $rel = $url == get_attachment_link($attachment_id);
        return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size, $alt);
    }
    return $html;
}

WordPress Version: 4.1

/**
 * {@internal Missing Short Description}}
 *
 * @since 2.5.0
 *
 * @param string $html
 * @param integer $attachment_id
 * @param array $attachment
 * @return string
 */
function image_media_send_to_editor($html, $attachment_id, $attachment)
{
    $post = get_post($attachment_id);
    if (substr($post->post_mime_type, 0, 5) == 'image') {
        $url = $attachment['url'];
        $align = (!empty($attachment['align'])) ? $attachment['align'] : 'none';
        $size = (!empty($attachment['image-size'])) ? $attachment['image-size'] : 'medium';
        $alt = (!empty($attachment['image_alt'])) ? $attachment['image_alt'] : '';
        $rel = $url == get_attachment_link($attachment_id);
        return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size, $alt);
    }
    return $html;
}

WordPress Version: 3.7

/**
 * {@internal Missing Short Description}}
 *
 * @since 2.5.0
 *
 * @param string $html
 * @param integer $attachment_id
 * @param array $attachment
 * @return array
 */
function image_media_send_to_editor($html, $attachment_id, $attachment)
{
    $post = get_post($attachment_id);
    if (substr($post->post_mime_type, 0, 5) == 'image') {
        $url = $attachment['url'];
        $align = (!empty($attachment['align'])) ? $attachment['align'] : 'none';
        $size = (!empty($attachment['image-size'])) ? $attachment['image-size'] : 'medium';
        $alt = (!empty($attachment['image_alt'])) ? $attachment['image_alt'] : '';
        $rel = $url == get_attachment_link($attachment_id);
        return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size, $alt);
    }
    return $html;
}