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.

if I add this code in my theme function.php

add_image_size('thumb' , 130, 65, true ); // Thumb
add_image_size('max' , 610, 305, true );  // Maximum
add_image_size('min' , 270, 135, true );  // Minimum 

…the file names of uploaded images is:

  • photo-name-130x65.jpg
  • photo-name-610x305.jpg
  • photo-name-270x135.jpg
  • photo-name.jpg

How can I rename them to the following (by default)?

  • photo-name-thumb.jpg
  • photo-name-max.jpg
  • photo-name-min.jpg
  • photo-name.jpg

And if someone wonders why I want to do this is because: If in the future I decide to change theme, logically I might change because of the new theme the dimensions of the photos. So for what reason should I create too many dimensions when I can just replace them from the original, without taking to much space and so I won't delete the previous sizes and create 404 error in the indexing of the photos in Google.

share|improve this question
1  
First you should explain the "why". –  kaiser Feb 15 '12 at 10:18
1  
I see no benefit doing this especially when trying to do this in WordPress is going to involve a lot of work. As Kaiser said; why do you want to do this? –  Brady Feb 15 '12 at 15:18
    
I edited the theme and am answering your question. –  Alex Feb 16 '12 at 17:09
    
possible duplicate of Is it possible to modify default image name suffix? –  Chip Bennett Feb 16 '12 at 17:22

2 Answers 2

up vote 2 down vote accepted

If you want to ensure your image sizes remain available when switching themes, then you should place them into a plugin. Create a .php file (name it what you want) and place it in wp-content/plugins/, then paste the following:

<?php

/*
Plugin Name: My Custom Image Sizes
Plugin URI: http://pippinsplugins.com/
Description: Images sizes to be used in all themes
Author: Pippin Williamson
Author URI: http://pippinsplugins.com
Version: 1.0
*/

add_image_size('thumb' , 130, 65, true ); // Thumb
add_image_size('max' , 610, 305, true );  // Maximum
add_image_size('min' , 270, 135, true );  // Minimum

Once you activate the plugin, your image sizes will be available no matter what theme is activated.

share|improve this answer

when you change themes or adjust the media sizes you could just use the regenerate thumbnails plugin to ummmm... regenerate the thumbnails to the newly defined sizes. it may or may not delete the old ones... i couldn't say. your approach seems like a lot of effort for little gain.

share|improve this answer

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.