Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.59k stars 799 forks source link

Importing post with galleries doesn't work properly #22182

Open christianoliveira opened 2 years ago

christianoliveira commented 2 years ago

Impacted plugin

Jetpack

Steps to Reproduce

Feature "import" doesn't work properly when the imported post has galleries. I expect it to import the galleries and the images and the gallery to keep working, but instead of that when clicking an image in the gallery, another image is loaded.

The galleries were created using Jetpack Galleries

The import tools works ok in terms of actually importing the images to the Media database and showing them in the gallery, but it doesn't replace other fields that referes to the images that are important for the gallery to work properly, so some of the references of the images point to the previous ID (the ID of the image in the previous blog from where the post was imported) instead of the current ID of the image.

It also seems that when the old ID doesn't exist in the current wordpress installation, the image is nevertheless correctly loaded when clicking on it, but if the ID exists, the image associated with that ID is loaded instead.

You can see this in action in this published post:

https://randomtrip.pt/guia-terceira-acores/

The post was imported and translated from https://randomtrip.es/guia-terceira-azores/ . The galleries show the correct pictures, but when clicking on them (when opening the gallery) in some cases the image loaded is completely different from the image in the gallery.

When inspecting the code of the first gallery, we can see that there are several references to randomtrip.es that should've been updated when importing the post, but they are not. Also, the IDs included in the first line (the one that defines the blog) are the IDs of the images in the origin post (the one imported), not on the current one. (red: incorrect references. green: correct references)

import-galleries-not-working

The actual IDs of those images in randomtrip.pt are:

https://randomtrip.pt/wp-content/uploads/2021/12/angra-do-heroismo-prainha-1024x683.jpg => 10771 https://randomtrip.pt/wp-content/uploads/2021/12/angra-do-heroismo-porto-1024x683.jpg => 10772 https://randomtrip.pt/wp-content/uploads/2021/12/angra-do-heroismo-igreja-da-misericordia-1024x683.jpg => 10773 https://randomtrip.pt/wp-content/uploads/2021/12/angra-do-heroismo-vasco-da-gama-1024x683.jpg => 10774

A clear and concise description of what you expected to happen.

When importing a post with Galleries using the Wordpress Import tool, I expect that:

What actually happened

The import post includes the galleries and imported the images to the Media library, but the Jetpack gallery code references in some of the fields to incorrect data (the ids and URLs of the images in the original exported post instead of the current imported post).

When clicking on an image in the gallery, sometimes an image different from the one in the gallery is loaded.

Other information

https://videopress.com/v/Hp7TyNyi

Operating System

macOS

OS Version

12.0.1

Browser

Chrome/Chromium

Browser Version(s)

96.0.4664.110

jeherve commented 2 years ago

Good catch, thank you for the report. This does indeed seem to be an issue when importing posts on sites that already have some media, and thus where post IDs do not match after the import.

christianoliveira commented 2 years ago

@jeherve thanks for your reply!

I suppose this will depend on a lot of things, but as a user, what should I do until this is solved? I already have several big posts (>40 galleries each) like that, imported and translated, with "incorrect IDs". Right now the only solution I see is to try to manually update the IDs, or try to develop a script that does that automatically, I don't know if there is other option.

Since when the ID imported does not match any image in the site, the gallery works fine, is it maybe possible to force Jetpack to ignore those IDs?

jeherve commented 2 years ago

I'm afraid I cannot think of an easy workaround; updating the IDs will indeed be your best bet but it's going to take some time. You could try doing that via the post editor interface and the button that appears above the block when this validation error happens.

christianoliveira commented 1 year ago

Hi again! Some months have passed since opening this issue, is there any update about it and/or an estimated date when it will be addressed?

coder-karen commented 1 year ago

Hi @christianoliveira thanks for checking in, unfortunately we have no further update at the moment (nor estimated date).