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 );
}
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.
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
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.
Thank you Beda,
Sorry about my garbled english in the last update.
cheers
No, my apologies for not having caught it earlier 🙂
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/
Beda,
thank you - I was tied up but I just confirmed the fix worked.
thank you for the quick action.
bryan