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

Image src may not match attachment ID #23702

Closed
azaozz opened this issue Jul 6, 2020 · 3 comments · Fixed by #23703
Closed

Image src may not match attachment ID #23702

azaozz opened this issue Jul 6, 2020 · 3 comments · Fixed by #23703
Assignees
Labels
[Status] In Progress Tracking issues with work in progress

Comments

@azaozz
Copy link
Contributor

azaozz commented Jul 6, 2020

Describe the bug
When editing an image, the "Save" request relies on the attachment ID in the image block. However in some edge cases that ID may not match the edited image's attachment. For example after all posts have been exported from one website and imported in another.

Then, if the wrong attachment ID is not for an image, the Save request fails, but if the wrong ID is for another image's attachment, the other image is edited and replaced in the image block.

To reproduce
Steps to reproduce the behavior:

  1. Upload two images and add them to a post.
  2. From the Code editor replace the ID on the first image (in the block's args and in the wp-image-nnnn class) with the ID for the second. Save and preview the post, notice the first image doesn't have srcset, etc, as the attachment ID is wrong.
  3. Edit the first image and save. At this point the edits are applied to the second image, and the first image is replaced with the second.

To fix it will need to use the new wp_image_file_matches_image_meta() on the API side to confirm the src and attachment ID are for the same image.

Opened https://core.trac.wordpress.org/ticket/50565 for trunk.

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Jul 6, 2020
@margarita-boomCodes
Copy link

Unfortunately I just had the same issue with the latest 5.9.2 WP Version.

The content was imported with WP All Import and the images carried their old IDs. If I change the image size from the dropdown, the image is being replaced by another image with the "wrong" ID is defined in the block.

@AgitateCurtis
Copy link

Likewise, this issue is persisting for me with same WP All Import scenario

@slam-campup
Copy link

slam-campup commented Jul 27, 2023

Same experience here, also with WP All Import content.

The missing or incorrect attachment ID also breaks srcset and the Image Size block option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] In Progress Tracking issues with work in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants