Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #667598

    Hi! I’m trying to add some custom entries for the image size dropdown menu to be selected when I add a new image on a page.

    I’ve found this post which seemed very neat: https://kriesi.at/support/topic/best-way-to-add-image-sizes/

    I copied and pasted the code in my functions.php file (I’m using an Enfold-child theme) but no “bigger-square” new size is displayed in the dropdown menu when I add an image.

    I then went through many other posts that dealt with the same problem, tried what them all suggested but I had no luck.

    I think I’m missing something, could you help me?

    #667601

    well to me it works nice – but you have to know that this will only have an effect for newly (after that functions.php entry) uploaded Images !
    But if you want that every image in your media library gets the new format than there are some nice plugins to solve this with one klick (Regenerate Thumbnails f.e.)

    #667602

    maybe this seems to be better: https://wordpress.org/plugins/force-regenerate-thumbnails/

    PS: WordPress itself reduces by default all images (maybe it is only jpg) to 90% Quality (not size) – if you don’t like that – because all images are optimized perfectly than you can add the following to functions.php:

    add_filter( ‘jpeg_quality’, create_function( ”, ‘return 100;’ ) );

    #667654

    Thanks a lot for the quick reply. The fact that the modification affected only newly uploaded images wasn’t 100% clear to me, but I had tried uploading a new image, just as a test, and it didn’t work.

    I’ve tried the plugin you suggested. It lets you force to regenerate the whole media library or a single picture. I tried with a single picture and now I see the new size in the pulgin’s report. This is what the plugin report says after forcing regeneration on a single image:

    “Regenerate: 1030×1030, 120×120, 1210×423, 1500×1500, 1500×430, 1500×630, 180×180, 250×250, 260×185, 300×300, 36×36, 450×450, 495×400, 705×705, 710×375, 768×768, 80×80, 845×321, 845×684
    Successfully regenerated in 25,126 seconds”

    250×250 is the new size I added in functions.php, I see it in the report but I don’t see it in the drop-down menu inside the Avia Builder. In fact the report lists 19 sizes, while I only see 11 choices in the drop-down menu. I know that sizes which are bigger than the actual size of the image are not listed, but that’s not the case ’cause the image I’ve uploaded is 2980x2980px, so every possible size should be listed.

    I’m still missing something. Any thoughts?

    #667658

    the point is that on uploading an image WordPress generates those given sizes and stores it under the known names.

    it only is in the dropdown list if the image has that calculated size – so have a look after you have done the resize thumbnails and see again

    (PS : you have to mark those images you want to be resized )
    the force regenerate thumbnails has the advantage that the old images are erased and newly calculated.
    So if you change perhaps the wordpress media dimensions the old ones are erased and did not waste memory on your server.

    • This reply was modified 8 years, 3 months ago by Guenni007.
    #667667

    Thanks again, but unfortunately it does’t work.

    #667675

    Thanks again Guenni007, I finally had some luck. Found this code, it works:

    if ( function_exists( ‘add_image_size’ ) ) {
    add_image_size( ‘new-size’, 350, 250, true ); //(cropped)
    }
    add_filter(‘image_size_names_choose’, ‘my_image_sizes’);
    function my_image_sizes($sizes) {
    $addsizes = array(
    “new-size” => __( “New Size”)
    );
    $newsizes = array_merge($sizes, $addsizes);
    return $newsizes;
    }

    #667679

    the code of your link above does work too – i tested it on my testenvironment (but perhaps you give it a second choice) without the uncommenting lines:

    add_image_size( 'bigger-square', 250, 250, true );
    add_filter( 'image_size_names_choose', 'my_custom_sizes' );
    function my_custom_sizes( $sizes ) {
        return array_merge( $sizes, array(
            'bigger-square' => __( 'Bigger Square' ),
        ) );
    }
    #669226

    Hi @kykkoko,

    Did you get your problem fixed? Thanks @Guenni007 for helping out :-)

    Best regards,
    Rikard

    #669305

    I did! Sorry not to having pointed out that explicitly. Thanks to Guenni007 and to everyone.

    #669657

    Hi,

    No problem, glad you got help from @Guenni007 :-)

    Please open a new thread if you should have any further questions or problems.

    Best regards,
    Rikard

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Add custom image size to Avia Layout Builder’ is closed to new replies.