Cover image cropping position

Hello,
I have a category image which is displayed upright on the home page (the original dimensions are 1600 x 2133 pixels). This is ok. My question is, how can HivePress say that the image is cropped from the top for the category view?

The image is cropped to 1600x800 pixels, but the center part of the image is the focus. But I want the focus to be on top.

In the WordPress settings I have already set under Media for the “Landscape (large)”. Format that the cropping should happen “Top & Center”. What also happens, however, the category image is a completely different format which does not appear in WordPress.

For clarification:
Original image: https://coalog.com/wp-content/uploads/2023/02/osjfgk.jpeg
Category image: https://coalog.com/wp-content/uploads/2023/02/osjfgk-1600x800.jpeg

Thanks in advance for your ideas

Hi,

If you mean cover image, this size is unavailable in Settings > Media.
This can be changed by creating a code snippet for the hook hivetheme/v1/image_sizes.

If customizations are required for your site, please try customizing it using the collection of code snippets Search · user:hivepress · GitHub and other developer resources, or consider hiring someone for custom work https://fvrr.co/32e7LvY.

Hello,

thank you for your answer. A new image size does not really help me. My problem is that the coverimage which is cropped to 1600x800px is cropping from the center. I just want the 800 px to be cropped from the top.

So the top 800pixels of the image should remain.

Under themes/listinghive/includes/configs/image-sizes.php I can only set if a crop should take place or not.

In the backend of Wordpress the “cover_large” is not selectable so that I could set here that the crop should take place from above as with the other formats.

Yes, it’s possible to adjust the cropping position, but this requires a code snippet for the hivetheme/v1/image_sizes It accepts the same parameters as the add_image_size() | Function | WordPress Developer Resources function/ This cropping parameter also accepts positions like ['center', 'top'].

Could you please provide a sample code snippet? Thank you.

I am trying to use the documentation that you are referring to, but since I am not a developer, I would appreciate your assistance. I want to choose a cropping position for a category image (instead of center). I want it to be different on desktop and mobile. Please provide a sample code that I can use it.

Thank you,
Givi

Hi,

Sorry for the delay.

Please try this PHP snippet ( It accepts the same parameters as the add_image_size() | Function | WordPress Developer Resources ):

add_filter(
	'hivetheme/v1/image_sizes',
	function( $image_sizes ) {
		$image_sizes[ 'landscape_small' ][ 'crop' ] = [ 'center', 'top' ];

		return $image_sizes;
	}
);

Please note that it can require further customization.

This code did not make any changes. The crop is still from the center.

Please try re-uploading the image or use the Regenerate Thumbnails plugin, these rules are applied only when the image is being uploaded.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.