Good to hear from you again; thanks for the kind words and for your question.
MLA uses a standard WordPress function, wp_get_attachment_image()
, to generate its thumbnail markup. There is an existing filter in that function you can hook to get the results you seek:
/**
* Filters the list of attachment image attributes.
*
* @since 2.8.0
*
* @param array $attr Attributes for the image markup.
* @param WP_Post $attachment Image attachment post.
* @param string|array $size Requested size. Image size or array of width and height values
* (in that order). Default 'thumbnail'.
*/
$attr = apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment, $size );
I am marking this topic resolved, but if you have any problems or further questions about using the above filter to accomplish your goal, post an update and I will investigate further. Thanks for your continued interest in the plugin.
Hi David,
Thanks for your response.
There is indeed a hook in the standard function wp_get_attachment_image()
, but all my pdf don’t go in this hook because in the function wp_get_attachment_image
, they don’t have image src..
But, I hook into function wp_get_attachment_image_src()
and I get the good result !
This is how I make, if someone is interested :
if(!function_exists('sp_change_icon_pdf_media')){
function sp_change_icon_pdf_media($image, $attachment_id, $size, $icon){
global $pagenow;
if(!is_admin() && $pagenow != 'upload.php') return $image;
$mime_type = get_post_mime_type($attachment_id);
if($mime_type == 'application/pdf'){
// Do stuff
$url = 'http://www.domain.com/test.jpg';
} else $url = '';
return array($url, 64, 64, $icon);
}
add_filter('wp_get_attachment_image_src', 'sp_change_icon_pdf_media', 10, 4);
}
Thanks again David,
Anthony
Thanks for adapting my suggestion and finding a better solution! Thanks as well for sharing your code so other users can benefit from it.