Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: Embed PDF Thumbnail with Link

Discussion in 'Misc WordPress Requests' started by lcssanches, Feb 23, 2018.

  1. lcssanches


    Reply To: Embed PDF Thumbnail with Link, by lcssanches


    I just make this filter as workaround

    function _add_media_pdf_thumbnail( $html, $id, $attach ) {

    $file_url = $attach['url'];
    $filetype = wp_check_filetype( $file_url );

    if( $filetype['ext'] == 'pdf' ){
    $thumb_url = wp_get_attachment_image_src( $id, 'medium' );

    $_html = '';
    $_html .= '<a href="'.$file_url.'" target="_blank">';
    $_html .= '<img src="'.$thumb_url[0].'" />';
    $_html .= '</a>';
    return $_html;

    return $html;
    add_filter( 'media_send_to_editor', '_add_media_pdf_thumbnail', 10, 3 );

    But looking at WordPress source, the thumbnail is only added for images, not other type of media.
    See https://developer.wordpress.org/reference/functions/wp_ajax_send_attachment_to_editor/

    Reply To: Embed PDF Thumbnail with Link

Share This Page

Monarch Social Sharing Plugin