WordPress.org

Ready to get started?Download WordPress

Forums

insert image size choose (17 posts)

  1. Bazan
    Member
    Posted 1 year ago #

    I want to insert image from media library to post.
    In older version, i could just select any pic and set its size to one from predefined list (large / small / custom-size-1 / custom-size-2).

    In version 3.5 i cant find anywhere this option. While choosing an image i can choose from select list - only one option - full size.

    I tried this:

    function my_insert_custom_image_sizes( $sizes ) {
        // get the custom image sizes
        global $_wp_additional_image_sizes;
        // if there are none, just return the built-in sizes
        if ( empty( $_wp_additional_image_sizes ) )
            return $sizes;
    
        // add all the custom sizes to the built-in sizes
        foreach ( $_wp_additional_image_sizes as $id => $data ) {
            // take the size ID (e.g., 'my-name'), replace hyphens with spaces,
            // and capitalise the first letter of each word
            if ( !isset($sizes[$id]) )
                $sizes[$id] = ucfirst( str_replace( '-', ' ', $id ) );
        }
    
        return $sizes;
    }
    
    function custom_image_setup () {
        add_theme_support( 'post-thumbnails' );
        add_image_size( 'custom-image-size-1', 160, 9999 ); //  small columned
        add_image_size( 'custom-image-size-2', 300, 9999 ); //  medium
        add_image_size( 'custom-image-size-3', 578, 190, true ); //  cropped
        add_filter( 'image_size_names_choose', 'my_insert_custom_image_sizes' );
    }
    
    add_action( 'after_setup_theme', 'custom_image_setup' );

    But it dont work.

    How to set a size to image in post?

  2. Amado.Miami
    Member
    Posted 1 year ago #

    Insert the media into your post or page.
    Then select the media and in the upper left corner will you get a
    small image icon. Select it and then you can scale down your image based on percentage.

  3. Bazan
    Member
    Posted 1 year ago #

    But i want to choose one from predefined like before,
    So i want to have a list of options that i can choose between

    (large / small / custom-size-1 / custom-size-2).

    Your solution will work but its not nice to user, and every single post will have various sizes.

  4. Amado.Miami
    Member
    Posted 1 year ago #

    When I look at my "Attachment Display Settings" on the very lower right hand side, when I go to insert my media I get - Full size, Medium, and thumbnail

  5. Bazan
    Member
    Posted 1 year ago #

    Hmm thats the problem.

    I have tried my php code in other WP site, and that works - i can choose all the options.

    My problem now is not adding new sizes but display these sizes in menu. I dont know why this menu shows only one position - full width, when the same theme on another server works fine :/

    Where and how I have to search this displaying bug - list of sizes?

  6. bcworkz
    Member
    Posted 1 year ago #

    A curious problem indeed. I've no idea what the problem may be. In such situations, it may be worth trying temporarily deactivating all the plugins. If the problem goes away, reactivate each plugin in turn until you find the one causing the problem to reappear.

    If the problem remains with plugins deactivated, reactivate them all and be glad you don't have find bugs in plugins.

  7. Bazan
    Member
    Posted 1 year ago #

    So im glad i dont have to find bugs in plugins :P

    Any other ideas?

  8. Bazan
    Member
    Posted 1 year ago #

    Hmm, on my localhost using WAMP server, I have installed latest WordPress, I can add media with all the various sizes from list. When i have installed the same wordpress on the web server, I can choose only full width, on twentytwelve theme. Tried it just after install wordpress. So i guess it's my server problem.

    GD support is enabled. Whats going on?!

  9. Amado.Miami
    Member
    Posted 1 year ago #

    Did you check your "Media Settings" inside of "Settings"/"Media"

    Specifically look at you Images Sizes information.
    The sizes listed below determine the maximum dimensions in pixels to use when inserting an image into the body of a post.

  10. Fastone
    Member
    Posted 1 year ago #

    Hey folks,

    Just to report. I have the same problem, and with all plugins deactivated. Trying to check on this now. Never seen this before.

  11. Fastone
    Member
    Posted 1 year ago #

    Ok, something happened now. I'm not really sure what I did that made this work.

    I deleted cash, and with all plugins deactivated, I switched to Twentyeleven WP default theme. I went to a page and tried to add an image to it. The size selector was now there.

    I then switched back to my WooThemes theme, and it works now. Trying to reactivate one plugin at a time.

  12. makbeta
    Member
    Posted 1 year ago #

    I've found a plugin Simple Image Sizes, it works it's magic via UI without the need to do any manual coding.

    It also includes thumbnail regeneration link, which is needed for any new size creations.

    Hope this helps.

  13. Fastone
    Member
    Posted 1 year ago #

    Hey Makbeta,

    Will look into this and check it out. I fixed it, but a better plugin for this would be nice.

    Thanks

  14. gcolefla
    Member
    Posted 1 year ago #

    Having the same problem now, any updates on this? Simple image sizes doesn't change anything.

    Now I am trying to figure out if I have a problem with GD support. Someone else installed this wordpress installation on a subdomain.

  15. Bazan
    Member
    Posted 1 year ago #

    After 2 months i have still a problem with image editor and image sizes, but - i have found that it dont work only for jpgs. If i upload gif it works fine, i can crop images, and choose image sizes, so the problem in my case is with a hosting service, not with wordpress actually.

    I am waiting for response from hosting administrator, i hope he will say me what was wrong and ill write it here :)

  16. gcolefla
    Member
    Posted 1 year ago #

    I think I found that there is no GD graphics library on our hosted server. I will try to remember to let everyone know if it fixes the problem.

    Bazan, I don't know what is wrong with your image sizes. If it works on wamp, and not on your server, there has to be something wrong with the hosting or maybe permissions? Wish I could help more.

  17. glee-nz
    Member
    Posted 1 year ago #

    Thank you Amado.Miami you have the correct answer that help us.

Topic Closed

This topic has been closed to new replies.

About this Topic