WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.39k stars 4.15k forks source link

Support embedded images, media and reusable blocks in Blocks import/export #10050

Open designsimply opened 6 years ago

designsimply commented 6 years ago

Steps to reproduce:

  1. Create a reusable block with a gallery of images.
  2. Open the block library by clicking on the inserter in the top toolbar.
  3. Click the gear icon in the "Reusable" section in the block library.
  4. Click "Export as JSON" for the reusable block from step 1.
  5. Open a different site and go to Posts > Add New.
  6. Open the block library by clicking on the inserter in the top toolbar.
  7. Click the gear icon in the "Reusable" section in the block library.
  8. Click the "Import from JSON" button at the top.
  9. Select the block exported from the other site.
  10. Try to edit the gallery images.

Result: the images are not actually imported and therefore cannot be modified via the imported reusable block. The following set of errors appears in the console for each image when the block loads:

GET http://madefortesting.com/wp-json/wp/v2/media/14448?context=edit 404 (Not Found) index.js?ver=1537381499:1 Uncaught (in promise) {code: "rest_post_invalid_id", message: "Invalid post ID.", data: {…}} index.js?ver=1537381499:1

screen shot 2018-09-19 at 6 04 00 pm

screen shot 2018-09-19 at 6 04 03 pm

Seen at http://madefortesting.com/wp-admin/post.php?post=616&action=edit running WordPress 4.9.8 and Gutenberg 3.9.0-rc.2 using Chrome 69.0.3497.92 on macOS 10.13.6.

Note: I used a gallery block in this test, but the problem applies to other blocks with images such as Cover Image.

What should happen for images inside reusable blocks? Should they be imported too? This seems complex. 🙂

noisysocks commented 5 years ago

This is a tough one...

My gut says that this isn't something we can fix. It's similar to how moving the database from one WordPress installation to another won't copy media over.

Thoughts, @youknowriad?

youknowriad commented 5 years ago

@noisysocks I think we should try to embed metadata about referenced items (media, reusable blocks...) in the exported file and try to import them and map them to their new values when importing. This is not an easy task but we should try to do it. (Elementor import/export for instance do something similar).

paaljoachim commented 3 years ago

Heya @noisysocks Robert and @youknowriad Riad. I am taking a trip down memory line through reusable blocks issues. Any thoughts on this issue at this current time? I assume we need to wait a while longer before approaching this again.

draganescu commented 3 years ago

I wonder with the introduction of patterns what is the use of this feature? cc @shaunandrews

jordesign commented 11 months ago

Looping back to this again after another 2 years....

Testing this with Synced Patterns - an image within the pattern references the absolute URL of the original image... So if the original site is still serving the image - it appears to be hot-linked...

Whilst it might be nice to have an option/action to import the image into the media library - it does at least display the image in the pattern in the imported site. Any thoughts @annezazu

annezazu commented 11 months ago

Whilst it might be nice to have an option/action to import the image into the media library - it does at least display the image in the pattern in the imported site. Any thoughts

I'd love to see an option to import the image, similar to what we have right now if you copy and paste content with an image from a google doc (there's an option in the block toolbar to import!).