Back to blog
5 min read Content Sync

Gallery and Cover Block Images After Copying a Post to Another WordPress Site

A Gallery block and a Cover block don’t just show images: they store attachment IDs and file URLs from the Media Library they were built in. Copy the post to another WordPress site as plain HTML, and those IDs point to other files or to nothing, the gallery comes up empty in the editor and the Cover block shows “This block contains unexpected or invalid content”. With Import Export by RockStarLab Content Sync, the images travel with the post and the blocks are updated to the files on the other site.

Free: Content Sync of posts and pages with their block images is in the free plugin. The test below used version 2.2.13 on both sites.

Short Answer

When you push a post, every image used in its Image, Gallery, Cover and Media & Text blocks is sent along. On the other site each image is added to the Media Library, or, if the same file is already there, the existing file is used. Then the attachment IDs and URLs in the blocks are changed to the files on that site, so the blocks open in the editor without errors. Pushing the post again doesn’t create duplicate images.

The post we pushed

The test post had a Cover block with a background image and a heading, a paragraph and a Gallery block with three images:

Block editor on the source site with a Cover block titled Our New Office, a paragraph and a three-image Gallery block
The test post: a Cover block, a paragraph and a Gallery block.

We pushed it from the editor: in the sidebar, Sync Content > Sync This Post, then the other site and Push to Site. You can also select several posts in Posts and use the Sync Content button above the list.

Sync Content dialog with one selected post, the receiving site chosen and the Push to Site and Pull from Site buttons
Sync This Post opens the Sync Content dialog in the editor.

The post didn’t exist on the other site yet, so it was created. On later pushes, Auto-match by Title finds the copy and updates it:

Map Posts for Sync dialog with Our New Office set to update the existing copy on the remote site
On the next push the copy on the other site is updated.

What the blocks look like on the other site

We opened the copy in the block editor on the receiving site. All blocks were valid: the Cover block, its heading, the paragraph, the Gallery block and the three Image blocks inside it, with no “unexpected or invalid content” warning and no empty image placeholders.

Block editor on the receiving site showing the same Cover block and Gallery with all images and no block warnings
The copy opens in the editor on the receiving site with all images.

We pushed the same post to two sites, to see both cases: files that already exist on the other site and files that don’t.

Receiving site Gallery images Cover image
Staging site that already had the same files The existing files were used (they were in an older uploads folder, 2022/05) The existing file was used
Multisite subsite without these files Three new images added to its Media Library The existing file was used
Same subsite, second push No new images, the three from the first push were used Unchanged

In every case the block attributes matched the files on the receiving site: the gallery images had the receiving site’s attachment IDs, and the Cover block’s image URL and ID pointed to the file in its own uploads folder, including the /sites/3/ folder of the multisite subsite.

Check your own post after a push

  • Open the copy in the block editor on the receiving site. A block with a problem shows a warning with Attempt recovery; a correct copy shows none.
  • In Media > Library on the receiving site, search for an image name to check that it is there once after one or more pushes.
  • If images are missing or still point to the source site, see images and links that broke after pushing staging to live.

As before any push, back up the site you push to, or ask your AI agent to start the backup.

With an AI agent

Import Export by RockStarLab gives AI agents its exports, imports and Content Sync as abilities. Through the WordPress MCP Adapter, WordPress itself offers an agent only read-only abilities for site, user and environment information, so without the plugin the agent cannot do the steps above (to connect an agent, see connecting Claude Code to WordPress). With it, one request is enough:

With Import Export by RockStarLab, push the post "Our New Office" to the cafe site, update the copy that is already there, and tell me which images were matched to existing files.

In our run, the agent called rsl-ie/sync-push with the post and the ID of the existing copy. The result listed 1 post updated and 4 images synced, with the image map from each source attachment ID to the attachment ID on the receiving site. The three gallery images mapped to the attachments created by the first push, so the Media Library got no new files.

FAQ

Why is my gallery empty after copying a post to another site?

The Gallery block stores attachment IDs from the source site. Copied as plain HTML, those IDs don’t exist on the other site or belong to other files. Content Sync copies the images and changes the IDs to the receiving site’s attachments.

Does pushing the same post again duplicate the images?

No. Images sent earlier, or the same files uploaded on the receiving site before, are used again.

Does it work for a site in a subfolder or a multisite subsite?

Yes. We pushed to a subsite of a subdirectory multisite, and the Cover block and gallery pointed to the subsite’s own uploads folder.

Which blocks are covered?

We tested Image, Gallery and Cover blocks. Media & Text, File, Video and Audio blocks that use Media Library files, and images in classic content, are sent the same way.

Get the free plugin on WordPress.org.

Dmitriy
About author

Dmitriy

WordPress Developer with 15+ years of commercial experience. Elite Author on ThemeForest and creator of custom WordPress plugins. Passionate about clean code, performance optimization, and building useful tools for the WordPress community.

JOIN THE CONVERSATION

Comments 0

Have a question or a tip to share? Leave it below.

Leave a comment

Your email address will not be published. Required fields are marked *

We store your name, email and comment to show and moderate it; your email is never published. Spam protection is provided by Cloudflare Turnstile and profile pictures by Gravatar. See our Privacy Policy.


Try the plugin with no risks!

New users get 1 month with access to all premium features. Experience the most powerful WordPress data engine today.

Download Now
Get PRO for FREE