743 posts
  • Elite Author
  • Weekly Top Seller
  • Featured Item
  • Most Wanted Winner
+5 more
Orbital_Themes
says

Is there any way to overwrite the default media settings (image sizes) from within my theme?

I don’t want to get thousands of support request about images having wrong sizes just because someone didn’t read theme documentation and didn’t set the image sizes correctly. :(

229 posts
  • 5 Years of Membership
  • Collector Level 1
  • Exclusive Author
  • United States
Pressateers
says
http://codex.wordpress.org/Function_Reference/add_image_size

Then when you use wp_get_attachment_src you specify the name of the size you added.

743 posts
  • Elite Author
  • Weekly Top Seller
  • Featured Item
  • Most Wanted Winner
+5 more
Orbital_Themes
says

I think you misunderstood me. I was asking about how to overwrite the default WP media settings. By default, when you install WordPress, the thumbnail size is set to 150×150.

Now I don’t wan’t to add separate thumbnail size, and this way create unnecessary bloat in uploads folder since my theme won’t even use the 150×150 size.

I wan’t to be able to overwrite media settings when my theme is activated. The set_post_thumbnail_size doesn’t seem to change the default 150×150 that is set in media settings.

229 posts
  • 5 Years of Membership
  • Collector Level 1
  • Exclusive Author
  • United States
Pressateers
says

I don’t believe it will physically change the value in Media Settings, but it will work for your theme provided you have this code set in functions.php:

 add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size(...);
1744 posts Building the Web.
  • Top Monthly Author
  • Trendsetter
  • Weekly Top Seller
  • Beta Tester
+10 more
ZoomIt
says

do a wpdb UPDATE query on theme activation for wp->prefix.’options’ ..

               64    0    thumbnail_size_w    150    yes
               65    0    thumbnail_size_h    150
and
67    0    medium_size_w    300    yes
               68    0    medium_size_h    300
and whatever you wish
743 posts
  • Elite Author
  • Weekly Top Seller
  • Featured Item
  • Most Wanted Winner
+5 more
Orbital_Themes
says

Nice, that’s what I was looking for :D But… Could you possibly share the full code for it? I’m not good in manually messing with database.

1744 posts Building the Web.
  • Top Monthly Author
  • Trendsetter
  • Weekly Top Seller
  • Beta Tester
+10 more
ZoomIt
says

Yeah sure -


if ( is_admin() && isset($_GET['activated'] ) && $pagenow == 'themes.php' ){
    global $DZSContactForm, $wpdb;

    $wpdb->query("UPDATE $wpdb->options
SET option_value='145'
WHERE option_name='thumbnail_size_w'");

    $wpdb->query("UPDATE $wpdb->options
SET option_value='145'
WHERE option_name='thumbnail_size_h'");

}

I charge 7,499.99US$ / hour – I’ll wait the payment on PayPal for an hour

743 posts
  • Elite Author
  • Weekly Top Seller
  • Featured Item
  • Most Wanted Winner
+5 more
Orbital_Themes
says

Thank you ZoomIt, this is a very nice function but I won’t pay for it. My girlfriend doesn’t like it too much. There is a reference to $DZSContactForm object, which, she says, is not utilized in my framework. She doesn’t like having undefined objects in my functions. Sorry for inconvenience.

Wish you all the best, Mateusz

1744 posts Building the Web.
  • Top Monthly Author
  • Trendsetter
  • Weekly Top Seller
  • Beta Tester
+10 more
ZoomIt
says

Yea, you can just delete that reference

Glad to help

743 posts
  • Elite Author
  • Weekly Top Seller
  • Featured Item
  • Most Wanted Winner
+5 more
Orbital_Themes
says

I was just kidding mate, thanks for helping :)

by
by
by
by
by
by