WordPress.org

Ready to get started?Download WordPress

Forums

Custom-sized Thumbnail (4 posts)

  1. Yofazza
    Member
    Posted 5 years ago #

    Hello,

    Could someone enlighten me.

    How can you create a custom-sized image attachment thumbnail that not depends on the Thumbnail Settings in Settings > Media?

    Specifically, I'd like to output a 100x75 zoom-cropped thumbnail that can't be changed from within the wp-admin Settings page.

    I tried image_resize() but it outputs a PHP Fatal Error where it says that wp_load_image() is an undefined function.

    Thank you!

  2. Yofazza
    Member
    Posted 5 years ago #

    Arr!

    1. Checked that both functions exists (in wp-includes/media.php and wp-admin/includes/image.php)
    2. Manually include wp-admin/includes/image.php before image_resize() is called in my function (because I thought it's an "admin only" inclusion)
    3. Error: Functions in wp-admin/includes/image.php is defined twice (wp-admin/includes/image.php is included twice - and I can't use include_once() because the second inclusion is after my function is called)
    4. Recreate image_resize() and wp_load_image() functionality in my function
    5. Problem solved, inefficiently

    I created my function in wp-content/themes/_themename_/functions.php. Don't know if I will not have this problem or not, if I create my function as a plugin (don't want to create a plugin because this is a theme-specific function).

    I think WordPress should include wp-admin/includes/image.php before including the theme's functions.php, no?

  3. wlindley
    Member
    Posted 5 years ago #

    Grmph. Yes, problem exists for plugins. I am trying to write a plugin and encountered this error.

    This is still broken in trunk version 11794 as of 2009-08-09.

  4. Yofazza
    Member
    Posted 5 years ago #

    Btw which is more efficient if we consider server process, bandwidth, bulky code, and possible native create_custom_thumbnail_size() function in the future?

    #1: To recreate the resizing functions.

    #2: Or to just use the smallest thumbnail size and change the dimension in HTML output? The "stretched/crippled" image will be hardly noticed if it's small.

    :D

Topic Closed

This topic has been closed to new replies.

About this Topic