[Gutenberg] Image size improvements#12983
Conversation
|
You can trigger an installable build for these changes by visiting CircleCI here. |
👍 I have caching turned on for Android as well. |
| requestURL = WPImageURLHelper.imageURLWithSize(size, forImageURL: requestURL) | ||
| request = URLRequest(url: requestURL) | ||
| } else { | ||
| } else if allowPhotonAPI { |
There was a problem hiding this comment.
@etoledom Can you clarify when allowPhotonAPI is set to true/false is there a related Gutenberg-Mobile PR where I can see the use of this argument?
There was a problem hiding this comment.
The previous behavior was to always fall back to the Photon API. With this change and setting allowPhotonAPI = true as default, all other instances continue working in the same way.
This PR uses allowPhotonAPI = false to fetch the image from the original URL directly and avoid the Photon resizing that affects the RN Image.getSize method.
There was a problem hiding this comment.
I'm giving this a second look trying to avoid introducing allowPhotonAPI.
There was a problem hiding this comment.
So, playing with the image scale we are able to get the desired result using the Photon Helper.
I believe it's ready for another 👀 @SergioEstevao 🙏
This makes download smaller images and less memory usage while editing
…tching Image.getSize() from JS
efdb2c4 to
b14c227
Compare
SergioEstevao
left a comment
There was a problem hiding this comment.
Working great, the new cache feature makes it so much better!
|
Thank you! |
Fixes n1 from wordpress-mobile/gutenberg-mobile#1593
In this PR, we avoid using the PhotonAPI helper, which was aggressively stripping the image size properties from the URL.
The
downloadImagemethod ofRCTImageURLLoaderis used by the JS functionImage.getSize()to retrieve the original image and calculate its size.I also took this opportunity to add a simple in-memory image cache to avoid fetching the same image multiple times.
To test:
Update release notes:
RELEASE-NOTES.txtif necessary.