Skip Navigation

[Resolved] Custom Image Size crop position is ignored

This thread is resolved. Here is a description of the problem and solution.

Problem:
I use the below shortcode to display a Featurd Image cropped to a custom size and crop location:

[wpv-post-featured-image size="custom" width="200" height="200" crop="true" crop_horizontal="right" crop_vertical="top"]

However, instead of cropping to the specified locations, it crops always with a centre-centre rule

Solution:
This is resolved in the latest Toolset Blocks and Views versions.
Please update the Plugins if still experiencing this issue.

0% of people find this useful.

This support ticket is created 4 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 7 replies, has 2 voices.

Last updated by bryan 4 years, 2 months ago.

Assisted by: Beda.

Author
Posts
#1438795
centercrop-top-crop.png

I am trying to:
Crop images to top

Link to a page where the issue can be seen:
hidden link

I expected to see:
.....the top parts of the image

Instead, I got:

crop to center

the problem seems to have come about at version 2.8.2

/application/models/shortcode/post/featured_image.php
when code was removed

 
	private function resize_image( $image_url, $width, $height, $crop ) {
		$uploads = wp_upload_dir();
		// Get image absolute path
		$file = str_replace( $uploads['baseurl'], $uploads['basedir'], $image_url );
		$suffix = "{$width}x{$height}";

		if ( false !== $crop ) {
			$suffix .= '_' . implode( '_', $crop );
		}

		$image = wpv_image_resize( $file, $width, $height, $crop, $suffix );

		if ( ! is_wp_error( $image ) ) {
			// Get image URL
			$image = str_replace( $uploads['basedir'], $uploads['baseurl'], $image );
		}

		return $image;
	}

was replaced with

	private function resize_image( $image_url, $width, $height, $crop ) {
		return $this->media->resize_image( $image_url, $width, $height, $crop );
	}
#1439401

The Toolset Types Image fields don't support any such attribute as crop_horizontal=”right” or crop_vertical=”top”
It allows to crop, but not to specify where it centres to when cropping, as far I know.
https://toolset.com/documentation/customizing-sites-using-php/functions/#image

It might be I miss myself a feature, in this case, please do not hesitate to correct me if you are using another method

Can you elaborate what field type you use and how you insert it in the page? It seems to me it is using Gutenberg, or Toolset Blocks, however, that is not possible if it was built with version 2.8.2 as only since 3.0.1 Toolset Views is also delivering the blocks features.

I am sure once I have the steps to replicate the issue we can issue a quick fix.
I indeed see we worked on Featured Images when version 2.8.2 was released.

#1447911
Screen Shot 2020-01-09 at 12.15.17.png

Beda,

thanks sorry for the delay replying.

Yes that's true for types images which is exactly why for this purpose I am using the featured image.

I am not using Toolset Blocks other than as a curiosity, I am using Views and then adding them as blocks in the Gutenberg editor.

Anyway, I am sure this is a bug because.

The syntax:

[wpv-post-featured-image size="custom" width="200" height="200" crop="true" crop_horizontal="right" crop_vertical="top"] 

....is generated by views, 2.8.2 and 3.0.2

and as a test I added the removed code back in to views 3.01 /application/models/shortcode/post/featured_image.php and the cropping worked fine. I

removed it again as I don't understand what the new code does and what else is relying on it, all I can say is the crop_vertical="top (which is what I care about) used to work and it stopped - I only noticed when a portrait photo I know used to display fine became headless !

In some cases I can overcome it with my own CSS but - I would rather things worked as they used to.

I can supply a test test but it's very easily reproducible with any person photo with a ratio of width being around half the height.

thanks

#1448231

You are right, the Featured Image ShortCode offers that attribute, in my tests ... none of the crops works at all.

I have escalated this and will investigate further to inform the developers.

#1448461

Thank you Beda,

Sorry about my garbled english in the last update.

cheers

#1448645

No, my apologies for not having caught it earlier 🙂

#1494133

This is now released in the latest versions of Blocks or Views, which you can download in Plugins > Commerical tab or on https://toolset.com/account/downloads/

#1506271

Beda,

thank you - I was tied up but I just confirmed the fix worked.

thank you for the quick action.

bryan

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.