Free Directory, Listing & Classifieds WordPress Plugin Support General HivePress How to change default images size?

How to change default images size?

  • Author
    Posts
  • blacklevel

    How to change default images size?
    All images created as 800×600 size. How to change this (for example I want 16:9 images)?

    ihordeveloper

    This code snippet should work (you can add it to the child theme functions.php file):

    add_filter(
    	'hivepress/v1/image_sizes',
    	function( $image_sizes ) {
    		return HivePress\Helpers\merge_arrays(
    			$image_sizes,
    			[
    				'landscape_small' => [
    					'width'  => 400,
    					'height' => 225,
    				],
    
    				'landscape_large' => [
    					'width'  => 800,
    					'height' => 450,
    				],
    			]
    		);
    	}
    );

    You can then re-generate thumbnails for existing images if there’re any https://wordpress.org/plugins/regenerate-thumbnails/

    Rede Cultura Torres

    It is possible to leave image proportion size of uploaded images? I feel that previous version of Hivepress worked that way:
    see here:
    https://redeculturatorres.org/listing/grito-rock/ (square logo, uploaded time ago)
    and new listing after new version:
    https://redeculturatorres.org/listing/rosa-de-venus-ao-vivo/ (square CD cover, uploaded yesterday)
    i need to leave img size as loaded, photos could be CD cover, logo, portrait photo, landscape photos…
    thanks in advance!

    ihordeveloper

    These images have the original size because they are smaller than 800×600 (e.g. the first one is 600×600 so it’s not resized/cropped). You can try overriding image settings using the above code snippet and set the height to “0”, then images will have the width of 800px max and the height will not be cropped, so there will be the original aspect ratio.

    Rede Cultura Torres

    Thanks! Like this? : (I’m not so close to coding)

    add_filter(
    ‘hivepress/v1/image_sizes’,
    function( $image_sizes ) {
    return HivePress\Helpers\merge_arrays(
    $image_sizes,
    [
    ‘landscape_small’ => [
    ‘width’ => 400,
    ‘height’ => 0,
    ],

    ‘landscape_large’ => [
    ‘width’ => 800,
    ‘height’ => 0,
    ],
    ]
    );
    }
    );

    ihordeveloper

    Sure, this one should work:

    add_filter(
    	'hivepress/v1/image_sizes',
    	function( $image_sizes ) {
    		return HivePress\Helpers\merge_arrays(
    			$image_sizes,
    			[
    				'landscape_small' => [
    					'height' => 0,
    				],
    
    				'landscape_large' => [
    					'height' => 0,
    				],
    			]
    		);
    	}
    );
Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

Subscribe

Sign In

Don't have an account? Register

Forgot password?

Register

Already have an account? Sign In

Forgot password?

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.