Mario Hernandez: SOLVED – Cannot crop based on original image after initial crop has been set

Mario Hernandez: SOLVED - Cannot crop based on original image after initial crop has been set

If you have read my posts about responsive images you will know I have done quite a bit of work with Drupal media and in particular, images. However, I recently ran into an issue I had not experienced before and it was quite challenging to comprehend. The issue was related to image cropping.
In our Drupal platform we allow content editors to manually crop images using a hand-full of crop types for various aspect ratios such as 1:1, 3:4, 4:3, 16:9, etc. To achieve the manual crop we use the Crop API and Image Widget Crop Drupal modules.

The issue we started noticing is that no matter the image we were using, all cropping settings were limited to a predefined aspect ratio of 1:1 or square, rather than the original image’s aspect ratio. This was causing big problems for us because editors were not able to properly crop images and as a result images were rendered with odd cropping settings.

After some research, I found an issue that had been reported in the Image Widget Crop module, issue #3222406. This was exactly the issue we were having and was relieved it wasn’t something unique to our platform.

Cause of the issue

Looking back, I think this issue was partly of my own making, but seeing that others were experiencing the same it’s also possible it was just an odd bug. Long story short, the issue was caused by using an image style with specific hard dimension, as the crop preview image, See Fig. 1 below.

Mario Hernandez: SOLVED - Cannot crop based on original image after initial crop has been set

Fig. 1: Screenshot of Crop preview configuration.

You may not know this but you can change image styles for almost any image within Drupal’s admin. I recently completed a lot of work around image styles within our platform and perhaps I unknowingly changed the image style used by Drupal’s crop preview. I can’t say for sure.

Solution

The issue was not so much the aspect ratio used in the image style used as the crop preview, but rather the hard dimensions of the image style. These dimensions were forcing all images, regardless of their aspect ratio, to use the square aspect ratio as the starting point for cropping, rather than the original image.
The solution is to use an image style that uses the Scale image effect, as the crop preview. The Scale image effect does not require image dimensions and thus allows your cropping area to always reset to the original image.

If you read comment #5 in the issue page you will see juamerico explanation of the issue in more detail and what he did to fix it.

Steps taken to address the issue

  1. I created a new image style called Crop preview with the Scale image effect as well as using a wide aspect ratio or crop type such as 16:9.
  2. I configured the Manage form display for the Image media type (admin/structure/media/manage/image/form-display), so it uses the new image style I just created. See Fig. 2 below

Image crop preview settings

Fig. 2: Screenshot of Manage form display settings for images.


NOTE: Your environment may be configured differently than mine and you may not have the same options as I do.

With the changes to the Crop preview image style, every time you crop the image you are dealing with the original image rather than an already cropped image.

In closing

The main reason for writing about this topic is so I know what to do next time I run into this issue. I hope you find this helpful.

Google threatened tech influencers unless they ‘preferred’ the Pixel

The tech review world has been full of murky deals between companies and influencers for years, but it appears Google finally crossed a line with the Pixel 9. The company’s invite-only Team Pixel program — which seeds Pixel products to influencers before public availability — stipulated that participating influencers were not allowed to feature Pixel products alongside competitors, and those who showed a preference for competing phones risked being kicked out of the program. For those hoping to break into the world of tech reviews, the new terms meant having to choose between keeping access or keeping their integrity. ↫ Victoria Song at The Verge Even though this ended up being organised and run by a third party, and Google addressed it immediately, it doesn’t surprise me at all that stuff like this happens. Anyone who has spent any time on tech YouTube, popular tech news sites, and content farms knows full well just how… Odd a lot of reviews and videos often feel. This is because a lot of review programs subtly – or not so subtly – imply that if you’re not positive enough, you’re going to be kicked out and won’t get the next batch of cool products to review, thereby harming your channel or website. Apple is a great example of a company that uses the threat of not getting review samples, event invites, and similar press benefits to gain positive media attention. I myself was kicked out of Apple’s review program and press pool way back during the Intel transition, because I mentioned the new Intel MacBook Pro got uncomfortably hot, and Apple really didn’t like that. They tried to pressure me to change the wording, but I didn’t budge, and consequently, that was the end of me getting any review items or press invites. I only ever accepted one Apple press invite, by the way, to their headquarters in The Netherlands, which was in Bunnik, of all places. Not much of value was lost without Apple press invites. Nobody wants to go to Bunnik. With every review of a loaned item on OSNews, you can be 100% sure there are no shenanigans, because I simply do not let anyone influence me. OSNews doesn’t live or die by getting reviews of the latest and greatest tech, so I have no incentive to deal with pushy, manipulative companies or PR people. I refused to budge to Apple 17 years ago, during my first year at OSNews, when I was in my early 20s – and I’ve never budged since, either. Now look at everyone getting press access from Apple, and think to yourself – would any of them tell Apple to get bent? That being said, I’d love to review the new Google Pixel 9 Pro Fold, if only to make fun of that horrid name. Hit me up, Google.

War Thunder – A quick look at Patch 1.47!

Video by via Dailymotion Source Quick video giving a rundown of the major additions in Patch 1.47. Apologies if not as in depth as usual, but quite busy for the next few days. Social Media ⬇️Bluesky: https://bsky.app/profile/toreno.bsky.socialFacebook Page: https://www.facebook.com/Toreno4Instagram: https://www.instagram.com/toreno170Mastodon: Toreno17@mastodon.socialThreads: https://www.threads.net/@toreno170Twitter: https://www.twitter.com/Toreno17Twitch: https://www.twitch.tv/toreno5/videos Game: War Thunder ⬅️ #warthunder #patch #update #devserver #toreno Go to … Read more

Full Stack Development Course in Rawalpindi & Islamabad

Video by via Dailymotion Source Our Website: https://futureittechnology.com/https://futureittechnology.com/All-Courses-List.html Join our Full Stack Development route in Rawalpindi and Islamabad, ideal for people who need to grasp both front-cease and lower back-quit net development. You’ll learn how to construct whole web programs from scratch the usage of famous technology like HTML, CSS, JavaScript, Node.js, and databases like … Read more

Botafoguense é demitido de cargo público após ato racista

Video by via Dailymotion Source Assista na íntegra: https://youtube.com/live/1PwI31nKZMM Baixe o app Panflix: https://www.panflix.com.br/ Inscreva-se no nosso canal:https://www.youtube.com/c/jovempannews Siga o canal “Jovem Pan News” no WhatsApp: https://whatsapp.com/channel/0029VaAxUvrGJP8Fz9QZH93S Entre no nosso site:http://jovempan.com.br/ Facebook:https://www.facebook.com/jovempannews Siga no Twitter:https://twitter.com/JovemPanNews Instagram:https://www.instagram.com/jovempannews/ TikTok: https://www.tiktok.com/@jovempannews Kwai:https://www.kwai.com/@jovempannews #JovemPan#JornalDaManhã Go to Source

Expectation vs Reality escaping cable ties climbing ropes Dex Agents Of Mystery | Netflix

Video by via Dailymotion Source Watch Agents of Mystery on Netflix: https://www.netflix.com/title/81731720 Subscribe to Netflix K-Content: https://bit.ly/2IiIXqVFollow Netflix K-Content on Instagram, Twitter, and Tiktok: @netflixkcontent #AgentsOfMystery #Zombieverse #Netflix ABOUT NETFLIX K-CONTENT Netflix K-Content is the channel that takes you deeper into all types of Netflix Korean Content you LOVE. Whether you’re in the mood for … Read more

Traveling: A Source of Joy for Manisha Koirala

Video by via Dailymotion Source Actress Manisha Koirala, who recently celebrated her birthday, has shared that she is an avid traveller, and being bitten by the wanderlust bug helps her to explore different people and cultures across the planet. On Saturday, the actress took to her Instagram, and shared a Reel in which she could … Read more