Support » Plugin: Slimage » settings of PDF thumbnails

  • Hrohh

    (@hrohh)


    Hi, sorry for spaming, but I like plugin very much! ๐Ÿ™‚

    in filter attachment_fields_to_edit you checking attachment, if is image. But we have also PDF thumbnails, which is not. I think, there it can be like below

    1) wp_get_attachment_metadata
    2) check if meta[sizes] is set
    3) get relative path of full image
    4) check extension over wp_check_filetype, if is jpg,png…

    Like this, it would be bulletproof. I have thumbnails of PDF, MP4 videos…

    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Giorgos Sarigiannidis

    (@gsarig)

    Hi,
    I tried to upload some PDFs but I didn’t see any thumbnails generated. I haven’t used that specific WordPress feature, so if you could give me some more details about the workflow you follow when uploading PDFs, I might be able to take a closer look.

    Thread Starter Hrohh

    (@hrohh)

    Hi, sorry for delay. You can look here

    Enhanced PDF Support in WordPress 4.7


    You need Imagick on server, but in 2020 it is standard on every modern hosting.

    For testing you can install https://wordpress.org/plugins/debug-media/

    Of course, you can pass own thumbnailing technique. I have for mp4 videos like below

    
    $attach_id = wp_insert_attachment( $attachment, $file_abs_url );
    
    $meta = wp_generate_attachment_metadata( $attach_id, $file['data']['file'] );
    
    // Include image.php.
    require_once( ABSPATH . 'wp-admin/includes/image.php' );
    
    $thumbnail = Free_Videos::get_instance()->download_file( $args['preview_url'], $video_name );
    
    $thumbnail_sizes = wp_create_image_subsizes( $thumbnail['data']['file'], $attach_id );
    $thumbnail_sizes['sizes']['full'] = array(
    	'file' => basename( $thumbnail_sizes['file'] ),
    	'width' => $thumbnail_sizes['width'],
    	'height' => $thumbnail_sizes['height'],
    	'mime-type' => $thumbnail['data']['type']
    );
    
    $meta['sizes'] = $thumbnail_sizes['sizes'];
    
    wp_update_attachment_metadata( $attach_id, $meta );	
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘settings of PDF thumbnails’ is closed to new replies.