I'm making a new theme for a blog that will be slightly narrower. Thus I need to resize every image and also change the image url in every post. Is there any kind of plugin handling this?
I'm making a new theme for a blog that will be slightly narrower. Thus I need to resize every image and also change the image url in every post. Is there any kind of plugin handling this?
Share Improve this question asked Jun 14, 2011 at 8:46 BoBozBoBoz 3561 gold badge5 silver badges15 bronze badges3 Answers
Reset to default 0This plugin might help you : Regenerate Thumbnails
Just change the image dimensions in WP's Media Settings and run the plugin.
in function.php you can define your default thumbnail size :
// Set featured image sizes
add_theme_support( 'post-thumbnails');
set_post_thumbnail_size( 320, 320);
And then you can even define different format which you can use in your custom theme
add_image_size( 'sidebar', 75, 75, true);
add_image_size( 'gallery', 159, 159, true);
function custom_gallery(){
global $post;
$args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'numberposts' => -1,
'orderby' => 'menu_order',
'order' => 'ASC',
'post_parent' => $post->ID,
'exclude' => get_post_thumbnail_id()
);
$images = get_posts($args);
foreach($images as $image){
if($images){
// use gallery size thumbnails
$thumbnail_array = image_downsize( $image->ID, 'gallery' );
$thumbnail_url = $thumbnail_array[0];
}
}
}
Wait, wait… How do you tell your SQL replace what height the thumbnail generated by wordpress is?
So far the only solution I found is to searh/replace all the filenames and get rid of the width, making it ending like picturename-100x.jpg and then either batch replace all the urls in the posts contents or by creating an .htaccess redirect to send any image like picturename-100x\d\d\d?.jpg to picturename-100.jpg
If you come up with a better solution, let me know!
Ideally, I'd like a plugin that figures out the height from the existing same-name images (disregarding 000x000.jpg) and to write the proper width-height.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745090422a4610661.html
评论列表(0条)