Forums

[resolved] how set default image size (11 posts)

  1. rahendz
    Member
    Posted 6 months ago #

    hello there.. i've develop my first wordpress theme.. and i hit the wall..

    can anybody help about how to set the default wordpress image/media size in function.php, i need override them to make it fit in my theme without touch the setting/media..

    thanks before..

  2. premiumwp
    Member
    Posted 6 months ago #

    You would need to modify a core WordPress file (not advisable) – media.php located in wp-includes

    Just do it like this: http://wordpress.tv/2009/01/05/changing-your-default-media-settings/

  3. rahendz
    Member
    Posted 6 months ago #

    yea.. i just think about it lately but is there any way tooverride without playing the wordpress core.. 'cause i hope my theme can be installed on all wordpress version and all website wordpress-based platform..

  4. vjpo
    Member
    Posted 6 months ago #

  5. rahendz
    Member
    Posted 6 months ago #

    thanks vjpo.. but is that code register new image size? or it can do override the default image size such as thumbnail, small, medium and large?

  6. vjpo
    Member
    Posted 6 months ago #

    Yes, this function registers new image sizes. To override default sizes you can use in functions.php something like

    add_theme_support('post-thumbnails');
    update_option('thumbnail_size_w', 150);
    update_option('thumbnail_size_h', 150);
    update_option('large_size_w', 500);

    You can easily find additional info and examples about this functions.
    Check also set_post_thumbnail_size and similar topic
    And to disable creating default image sizes you can set their H and W to 0 (Settings->Media)

  7. rahendz
    Member
    Posted 6 months ago #

    thanks vjpo.. can't wait to try it..

  8. rahendz
    Member
    Posted 6 months ago #

    um.. one more thing, it's right if i want to set the height of image to auto ( to keep the ratio ) just set to 0 or don't set it at all?

  9. vjpo
    Member
    Posted 6 months ago #

    add_image_size( 'my-thumb', 300, 9999 ); and add_image_size( 'my-thumb', 300); do the same - height is auto.
    looks the same with update_option('thumbnail_size_h', 0); if height wasn't overridden - there is a risk to get old thumb H

  10. rahendz
    Member
    Posted 6 months ago #

    thanks a lot vjpo.. :thumbsup:

  11. vjpo
    Member
    Posted 6 months ago #

    You are welcome :)

Reply

You must log in to post.

About this Topic