Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Alt and caption text written on images while the image was temporary is deleted. #16051

Merged

Conversation

@jorgefilipecosta
Copy link
Member

commented Jun 7, 2019

Fixes: #12202, #16746

Currently, the image alt text written while the image is temporary (points to a blob URL) is deleted as soon as the upload finishes.

This PR fixes the problem.
Alt attribute is not set when the upload is complete if the current image is temporary and an alt already exists.

Description

How has this been tested?

(to make the upload slow I used chrome dev tools network throttling)
I added an image block, I pressed the upload button, while the image is uploading I wrote some alt text. I verified that the al text was persisted when the upload finished.
I repeated the same test but instead of adding an image block I drag&dropped an image directly to the editor.
I added an image I wrote some alt text. I drag & dropped another image to replace the current image, I waited for the upload to complete and I verified the alt text was removed.

packages/block-library/src/image/edit.js Outdated Show resolved Hide resolved
const { id, url, alt } = this.props.attributes;
// If the current image is temporary but an alt text was meanwhile wrotten by the user,
// make sure the text is not overwritten.
if ( alt && isTemporaryImage( id, url ) ) {

This comment has been minimized.

Copy link
@epiqueras

epiqueras Jul 25, 2019

Contributor

Let's also take care of the caption here so that this can also close #16746 .

@jorgefilipecosta jorgefilipecosta force-pushed the fix/upload-deletes-alt-written-during-image-upload branch from 86b3eea to f5a01f2 Jul 26, 2019

@jorgefilipecosta jorgefilipecosta changed the title Fix: Alt text written on images while the image was temporary is deleted. Fix: Alt and caption text written on images while the image was temporary is deleted. Jul 26, 2019

@jorgefilipecosta

This comment has been minimized.

Copy link
Member Author

commented Jul 26, 2019

Hi @epiqueras, thank you for reviewing this PR! The PR was rebased and updated to also deal with the caption.

@jorgefilipecosta jorgefilipecosta force-pushed the fix/upload-deletes-alt-written-during-image-upload branch from f5a01f2 to b5e62ef Jul 26, 2019

The suggestion was applied.

@jorgefilipecosta jorgefilipecosta force-pushed the fix/upload-deletes-alt-written-during-image-upload branch from b5e62ef to b92780e Aug 6, 2019

@jorgefilipecosta jorgefilipecosta merged commit c148164 into master Aug 6, 2019

1 of 4 checks passed

Filter opened Filter opened
Details
Filter opened Filter opened
Details
Milestone It Milestone It
Details
Travis CI - Pull Request Build Passed
Details

@jorgefilipecosta jorgefilipecosta deleted the fix/upload-deletes-alt-written-during-image-upload branch Aug 6, 2019

@youknowriad youknowriad added this to the Gutenberg 6.3 milestone Aug 9, 2019

gziolo added a commit that referenced this pull request Aug 29, 2019
gziolo added a commit that referenced this pull request Aug 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.