Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

3 Answers

up vote 0 down vote accepted

This plugin might help you : Regenerate Thumbnails

Just change the image dimensions in WP's Media Settings and run the plugin.

share|improve this answer
    
Thanks! Any ideas on the image url that needs to be changed on every post? –  BoBoz Jun 14 '11 at 10:42
    
You are trying to change the urls of links to images that have the size appended to them, like myimge-100x75.jpg right? You could do that directly via SQL REPLACE queries. Or you could make a dump of your db and then do a search/replace on the content with a text editor or a a dedicated s&r tool like regexxer for example, and then re-import the db. –  mike23 Jun 14 '11 at 10:48
    
Thanks for suggestions. This must be a common issue doing redesigns. –  BoBoz Jun 14 '11 at 11:39
add comment

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];
        }
    }
}
share|improve this answer
add comment

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.

share|improve this answer
    
Sorry, I meant to get rid of the height from filenames and code, so the only required information for each photo will be the width. –  sergio Mar 9 '12 at 7:57
    
Searching and replacing like that in probably not a good idea. Images filenames beyond the original are stored in a serialized array in postmeta. Search + Replace on the database is likely to break the serialization. –  chrisguitarguy Mar 9 '12 at 14:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.