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

Ghost 2.0's zip file import does not update relative image paths as indicated in the docs when using mobiledoc cards #9821

Closed
ageitgey opened this issue Aug 24, 2018 · 8 comments
Labels
bug [triage] something behaving unexpectedly help wanted [triage] Ideal issues for contributors to help with import / upgrade life-cycle stuff: Importing, exporting, upgrading and migrating server / core Issues relating to the server or core of Ghost stale [triage] Issues that were closed to to lack of traction

Comments

@ageitgey
Copy link

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

  1. 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
@kirrg001 kirrg001 added the needs:info [triage] Blocked on missing information label Aug 24, 2018
@kirrg001 kirrg001 self-assigned this Aug 24, 2018
@pascalandy
Copy link

pascalandy commented Aug 28, 2018

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:

screen shot 2018-08-28 at 9 23 08 am

And here you see the broken image:

screen shot 2018-08-28 at 9 23 19 am

But once published, the picture appears normally

screen shot 2018-08-28 at 9 23 40 am

Technical details:

Ghost Version: 2.0.3
Node Version: 8.11.4
Browser/OS: Chrome 68 on macOS
Database: sqlite prod

@pascalandy
Copy link

@ageitgey do you share the Medium-to-Ghost utility publicly? I would be curious to try it!

@ageitgey
Copy link
Author

@pascalandy Sure, I just posted it here: https://github.com/ageitgey/medium_to_ghost

@ageitgey
Copy link
Author

ageitgey commented Sep 5, 2018

@kirrg001 You tagged this as needs info. Let me know if there is any additional info that I can provide. Thanks!

@kirrg001
Copy link
Contributor

@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 👍

@kirrg001 kirrg001 removed the needs:info [triage] Blocked on missing information label Sep 10, 2018
@kirrg001 kirrg001 removed their assignment Sep 10, 2018
@kirrg001 kirrg001 added server / core Issues relating to the server or core of Ghost import / upgrade life-cycle stuff: Importing, exporting, upgrading and migrating bug [triage] something behaving unexpectedly help wanted [triage] Ideal issues for contributors to help with labels Sep 10, 2018
@stale
Copy link

stale bot commented Jan 24, 2019

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.

@stale stale bot added the stale [triage] Issues that were closed to to lack of traction label Jan 24, 2019
@ErisDS ErisDS removed stale [triage] Issues that were closed to to lack of traction labels Jan 25, 2019
@ErisDS
Copy link
Member

ErisDS commented Jan 25, 2019

We will be revisiting the importer after the ongoing API work.

@stale
Copy link

stale bot commented Apr 25, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [triage] something behaving unexpectedly help wanted [triage] Ideal issues for contributors to help with import / upgrade life-cycle stuff: Importing, exporting, upgrading and migrating server / core Issues relating to the server or core of Ghost stale [triage] Issues that were closed to to lack of traction
Projects
None yet
Development

No branches or pull requests

4 participants