Closed kevinfunk closed 4 years ago
Was able to narrow this down to just edits. By default, nothing has a crop set up yet, so it should always be 50,50 when you first install.
After that, things can change. One thing we were doing during the presave
setup here was using setValue()
on the image
field using an entire array. It works better to only update the ID and alt tags using the actual entity field object like $entity->image->alt = $entity->label();
Once we switched to this it fixed the issue where 0,0 was being set as the crop coordinates when using media/image/edit
To be clear, this is the actual fix. I did do some other minor things (cleanup) in the commit.
Looks like we still have one edge case where newly created images via CDF import do not have any crop data even though they do have new crops added into the system. This is because they have the old crops in the CDF connected to them. We'll need to do a CDF re-export to fix this after manually fixing all the crops.
Images added via unsplash widget are not affected by any of this because they get the default crop OOTB via the UI.
One "fix" that can be applied is to keep the Unsplash value in place, but just re-save the image. This updates the image's crop value to be correct. So this should actually be fixed once we do that and re-export.
Confirmed after a fresh install that all the default images have a crop set and its not 0,0 so the new CDF fix worked.
Trying to update to Focal Point 1.1, I've noticed that the focal point is set to 0,0 by default. If you open a media item and save it without setting the focal point, you will get the error![Screen Shot 2019-09-19 at 8 38 52 AM](https://user-images.githubusercontent.com/25224235/65246353-5f5abe00-dabc-11e9-889d-ab15ba7d4405.png)
Warning: Division by zero in Drupal\focal_point\FocalPointManager->absoluteToRelative() (line 64 of /focal_point/src/FocalPointManager.php)