Ghost 2.0's zip file import does not update relative image paths as indicated in the docs when using mobiledoc cards
ageitgey opened this issue ยท 8 comments
Issue Summary
I wrote a Medium-to-Ghost utility that converts all the user's Medium posts into Ghost 2.0-compatible mobiledocs and creates an import zip file for Ghost containing a .json and the associated images. In general it works amazingly well and the result in Ghost is nearly identical to what the user had on Medium. Nice job with 2.0!
To include images in the Ghost mobiledoc posts, I'm inserting a mobiledoc card
of type image
with the src
set to the local path of the corresponding image in the zip file.
According to the docs:
When uploading a zip which includes both images and a JSON or markdown file, the relative path to the images from the JSON should match any relative path used inside the JSON/markdown data. Ghost will then attempt to update the image paths in the content of the JSON/markdown such that they will continue to work after importing.
However, this is not true when importing mobiledoc image cards. Ghost does not seem to update the image paths as it says.
Example: If an imported post's mobiledoc
has an image card that refers to src: "/medium_images/my_image.jpg"
, the imported post will have a broken image pointing to http://mydomain.com/medium_images/my_image.jpg
The only way to generate an imported post with working images is to create the mobiledoc image card with the src
attribute pointing to the full final path of the image after importing, i.e. /content/images/medium_images/my_image.jpg
on my development installation.
To Reproduce
- Import this example zip file into a Ghost 2.0 instance: broken_import.zip
Expected result: Post will have working image
Actual result: Post will have broken image link
Technical details:
- Ghost Version: 2.0.3
- Node Version: 8.11.4
- Browser/OS: Chrome 68 on macOS
- Database: sqlite development local install
After I upgraded from ghost 1.25.4 to 2.0.3 I have an issue with the new editor.
In ghost 1.xx I used relative paths to refer to my pictures.
The editor is now confused with this:
And here you see the broken image:
But once published, the picture appears normally
Technical details:
Ghost Version: 2.0.3
Node Version: 8.11.4
Browser/OS: Chrome 68 on macOS
Database: sqlite prod
@ageitgey do you share the Medium-to-Ghost utility publicly? I would be curious to try it!
@pascalandy Sure, I just posted it here: https://github.com/ageitgey/medium_to_ghost
@kirrg001 You tagged this as needs info
. Let me know if there is any additional info that I can provide. Thanks!
@ageitgey Thanks for the Medium to Ghost utility - i have added your repository link to our importer docs ๐
I can confirm, this does not work. I have updated our 2.x importer docs.
The importer logic must check if the card src matches any image from the uploaded zip. Only then we should add the /content/images/
path. Otherwise it could be an external image link.
This is the code section which probably needs a tweak.
PR is welcome ๐
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
We will be revisiting the importer after the ongoing API work.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.