1

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?

2 Answers 2

0

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.

2
  • 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)? Apr 16, 2013 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. Apr 18, 2013 at 15:16
0

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.

1
  • Thanks for your answer Zlatev. The thing is that I know the hows but I am not sure what is the best practice. Apr 16, 2013 at 20:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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