Featured Image does not hard-crop
-
Hey guys,
First things first: I am a complete noob when it comes to WP and PHP. I have to say though, that I never really got my head around PHP.
My problem is (and i tried this for days with countless different approaches): I’d like the excerpts of posts I made to show those featured images and hard-crop those.
I’m working with a child theme of Thematic, installed under WP 3.4.1 locally in a test environment using MAMP, running PHP 5.3.6.
The code I use is located in the theme-child-folder’s functions.php file. The code does work, regarding the shortening of excerpts and showing a ‘read more’ link. It also shows a photo, however, what I didn’t accomplish is to hard-crop the photo. It always just shows the complete photo, scaled down the maximum dimensions, defined in the code below.
<?php
//use excerpts on home page
function child_content($content) {
if ( is_home() ) {
$content = ‘excerpt’;
}
return $content;
}
add_filter(‘thematic_content’, ‘child_content’);// excerpt read more links- adds a read more link to every excerpt- including manual ones
function all_excerpts_get_more_link($post_excerpt) {return $post_excerpt . ‘<span class=”readmore”>ID) . ‘”>’ . ‘Read more’ . ‘</span>’;
}
add_filter(‘wp_trim_excerpt’, ‘all_excerpts_get_more_link’);// change […] to … or whatever
function excerpt_ellipse($text) {
return str_replace(‘[…]’, ‘…’, $text);
}
add_filter(‘get_the_excerpt’, ‘excerpt_ellipse’);//change length of excerpt
function new_excerpt_length($length) {
return 40;
}
add_filter(‘excerpt_length’, ‘new_excerpt_length’);function child_post_thumb() {
return array(200,200);
}
add_filter(‘thematic_post_thumb_size’,’child_post_thumb’);
?>Thanks guys…
- The topic ‘Featured Image does not hard-crop’ is closed to new replies.