• Hi
    i’m using this function

    add_image_size( ‘in_post_image’, 1200, 800 );

    to add the option to insert images in post at that given size.
    Wp correctly save an image with width 1200px but when i insert an image in a post a can’t get the option to come out in the attachment drops down, which lists only the thumbnail, medium, large and fullsize options.

    Another solution would be to change only the size of the large option but how do i do that?
    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator cubecolour

    (@numeeja)

    You can also make your custom sizes selectable from your WordPress admin. To do so, you have to use the image_size_names_choose hook to assign them a normal, human-readable name

    add_filter( 'image_size_names_choose', 'my_custom_sizes' );
    
    function my_custom_sizes( $sizes ) {
        return array_merge( $sizes, array(
            'in_post_image' => __('In Post Image'),
        ) );
    }

    See https://codex.www.ads-software.com/Function_Reference/add_image_size#For_Media_Library_Images_.28Admin.29

    Thread Starter hcvitto

    (@hcvitto)

    I managed to add the option to the dropdown but i can’t understand how it wp makes it work.
    This is my code in functions.php

    if ( function_exists( 'add_image_size' ) ) {
    	add_image_size( 'in-post', 1200, 9999, true );
    }
    add_filter( 'image_size_names_choose', 'my_custom_sizes' );
    function my_custom_sizes( $sizes ) {
        return array_merge( $sizes, array(
            'in-post' => __('In post'),
        ) );
    }

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    but when i upload an img (1920×1200) the image is sized and uploaded correctly but the option in the dropdown says:
    In post – 625 x 390
    so I can’t choose to insert the correct img in the post. I got no idea where these dimensions come from and why it does not get the dimension i set (which should be 1200xheight).

    Moderator cubecolour

    (@numeeja)

    Did you add that code after the image was originally added to the site? if so, install the regenerate thumbnails plugin and regenerate the thumbnails for that image

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘added image size not showing in dropdown options’ is closed to new replies.