Hello
yes you can use the “bawmrp_no_thumb” filter, like this:
function catch_my_first_image( $image, $post_id )
{
$_post = get_post( $post_id );
if( !$_post ) return $image;
$image = preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $_post->post_content, $matches );
if( isset( $matches[1][0] ) )
$image = $matches[1][0];
return $image;
}
add_filter( 'bawmrp_no_thumb', 'my_own_bawmrp_thumb' );
function my_own_bawmrp_thumb( $thumb, $post_id )
{
return catch_my_first_image( $thumb, $post_id );
}
You can also use the “bawmrp_thumb_size” to change the thumb zize, like this:
add_filter( ‘bawmrp_no_thumb’, ‘my_own_bawmrp_thumb’ );
function my_own_bawmrp_thumb_size( $sizes )
{
return array( '64', '64' ); // only 64px
}
ps : not tested, just coded here.
Many Thanks Julio,
last question around this :). I’m not really a strong wordpress user so i’d like to know where I must put this code. Is it in the function.php, a plugin file, or in any other place?
François
Sorry, copy/paste this in your functions.php from your activated theme folder.
ok thank you. I think I must have a problem with my theme because this is not working. I’m using a wootheme typebased and for what i have seen in another module perhaps I miss some thumb functionnalities
François
ok I think I have no problem with my theme at the end. I rmeoved plugin cach and now images are broken. When I inspect element I see this:
<img src="0" height="100" width="100"> where the image url is replaced by ‘0’ perhaps there is a problem in the code you just made ?
my bad this is:
add_filter( 'bawmrp_no_thumb', 'my_own_bawmrp_thumb', 10, 2 );
and NOT
add_filter( 'bawmrp_no_thumb', 'my_own_bawmrp_thumb' );