Modifying protexted image sizes: use “add_image_size()” or “update_option()”?


I’m finding conflicting info on whether it’s okay to override protected WordPress image sizes (thumbnail, medium, medium_large, and large) with add_image_size(). Some docs indicate it’s better to do this with update_option (). Is there a practical difference between these sets of code:

function mytheme_image_sizes() {
  add_image_size('thumbnail', 200, 200, true);    
  add_image_size('medium', 480, 480, true); 


function mytheme_image_sizes() {
  update_option( 'thumbnail_size_w', 200 );
  update_option( 'thumbnail_size_h', 200 );
  update_option( 'thumbnail_crop', 1 );
  update_option( 'medium_size_w', 480 );
  update_option( 'medium_size_h', 480 );
  update_option( 'medium_crop', 1 );

Note: I’m specifying these in my theme to stop admins from arbitrarily altering sizes and screwing up the post-4.4 responsive images function, and I’ll probably remove the admin interface to change the image sizes.

, Slam 8 years 2016-04-18T17:08:18-05:00 0 Answers 87 views 0

Leave an answer