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

Switch to opt-in image sideloading #30

Open
dlh01 opened this issue Oct 6, 2024 · 0 comments
Open

Switch to opt-in image sideloading #30

dlh01 opened this issue Oct 6, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@dlh01
Copy link
Member

dlh01 commented Oct 6, 2024

Description

During a recent migration to WordPress from another CMS, we struggled to work around the block converter's current behavior of sideloading all images that it encounters. It would be helpful to be able to tell the block converter to use an existing attachment for an image block, and it would be helpful to be able to create image blocks where the image comes from only a URL, not an attachment.

Use Case

We had two cases in which we didn't want sideloading to occur:

  1. When we had already imported the images as part of other migration logic and wanted the block converter to reuse those attachments.
  2. When the images were hosted on other sites, in which case we didn't want to sideload them at all, but instead migrate them as image blocks referencing the external URL.

As far as I can tell, there aren't filters or other means for controlling sideloading behavior that accommodates these cases. The wp_block_converter_sanitized_image_url filter runs after the converter has already committed to uploading the image to the site. We could have used a macro, but at the expense of having to recreate the rest of the block converter's logic for creating image blocks.

To me, the risk of inadvertently copying loads of images from third parties as part of using the block converter is reason enough to switch to an opt-in model, where all image blocks are created as "from URL" image blocks unless the developer specifies that the image should be sideloaded. But I can be persuaded in a different direction about that.

@dlh01 dlh01 added the enhancement New feature or request label Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant