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 want to change default image sizes when user activates my theme so that the default medium image width is exactly the width of page content (for pages with sidebar) and the large image size fits nicely on full-width templates.

Is it considered a bad practice?

share|improve this question
add comment

2 Answers 2

up vote 0 down vote accepted

Best practice would be to implement your own post_thumbnails. Then, add those sizes as options in the Add Media dialog. Here is a nice write up on that.

share|improve this answer
    
Thanks for the article link, I will definitely use this method (was wondering how to do that too). Could you elaborate why you think that it's better to add yet another image size while leaving the default media sizes unused (aside from the scenario when users places the image into the post by himself)? –  Mateusz Hajdziony Apr 16 '13 at 20:30
    
Well, your Theme could define the default sizes, but what if the user decides to change them to something different after activation? You then have a confused user I think. Locking a user out of this default is bad practice. I would not use a theme that removes core functionality. Also, the 3 sizes created by WP are called Thumbnail, Medium, and Large respectively. Your sizes could have context for your Theme eg. (Full Page Width, Home Page Slide, Author Image etc.). The user has the option to use, but not to change these without hacking the theme itself. –  Nathan Powell Apr 18 '13 at 15:16
add comment

The use of functions set_post_thumbnail_size and add_image_size is not persistent and they should be executed on every load in order to take effect. That said you really don't need to worry about (de)activation and hook these to init action. If you need earlier action for some reason use after_setup_theme.

share|improve this answer
    
Thanks for your answer Zlatev. The thing is that I know the hows but I am not sure what is the best practice. –  Mateusz Hajdziony Apr 16 '13 at 20:25
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.