Exporting Thumbnails
Closed this issue ยท 13 comments
Hi Will,
That plugin is amazing, thank you so much for sharing it.
I'm trying export custom type posts from WordPress but I'm unable to export thumbnails from custom posts types, also exporting normal "posts" doesn't export the image thumbnail.
I had a local environment from wordpress running and I'm exporting the xml directly from Wordpress to each custom post types, from each individual file I can generate the .md files but non of my custom posts is getting the thumbnail.
Please if you have any suggestions let me know
Thank you again.
Hello Reinaldo! I did find a bug related to this. Just pushed a fix. Please try again with v2.0.5.
It works Will. Thank you
Awesome.
I also meant to ask about the custom post types thing... Would you be comfortable sending me your export file (if it doesn't have private/sensitive data in it) and the name of the custom post type(s) you're trying to get? That would be helpful for me to test and add that feature.
@rfos thank you! There's so much data there haha, excellent help for testing.
I created a branch that can parse out multiple post types: https://github.com/lonekorean/wordpress-export-to-markdown/tree/multiple-post-types
So basically...
- Clone that branch
- Edit
src/settings.js
to setpost_types
to all the post types you want - Run script as normal
The output should be all the posts of the post types you asked for, organized into folders.
I'll probably merge this to master soon, but if you had any feedback I'd love to hear it.
Alright, I pushed another commit to that branch that changes how it works.
It is now a question in the wizard ("Include custom post types and pages?") and will automatically find all custom post types. I try not to add more questions to the wizard to keep things simple, but this feature might be worth it.
It seems to work well, but I am not 100% sure that people would not prefer listing the post types they want manually.
Also, your export file is so huge, I had to increase the amount of memory node can use. ๐
node --max-old-space-size=8192 index.js
Thank you @lonekorean
I started testing that new version and I'm having some troubles while it's saving the images (around 7/8.000), I don't know what is happening but it just stops running. Probably because there are too many images to download.
I'm exporting the WordPress content to HUGO and saving images inside the same folder for each post can be a problem because Hugo considers images inside the static/
folder and not inside the post folder (especially when using a template).
I ready in somewhere a tutorial about how to pass the original path for images, example: wp-content/uploads/2019/07/20-years-of-file-20-years-of-art-and-technology-file-festival-new-media-caucus.jpg
, it would be easy to preserve the original folder structure allowing a simple copy and paste from wp-content/uploads
to static/uploads/
.
To adapt your code I added the type to the markdown file:
parses.js
line 68
frontmatter: { title: getPostTitle(post), date: getPostDate(post), categories: getCategories(post), tags: getTags(post), type: postType },
Great job!
Hey @rfos, so I've been working on things.
I updated the markdown parser this script uses, so it's more efficient, now I'm able to parse your entire export file without bumping up node's memory.
I found some encoding issues with downloading your images, and was able to adjust the script to work better for them. So now I'm able to get all but 132 of the images. The remaining images may be unused/removed images, not sure.
I also updated the script so that it will not try to save/download things that have already been saved/downloaded. Basically this means you can rerun the script to pick up where you left off. Useful if your internet connection dropped, computer crashed, etc.
It sounds like maybe you've figured out how to get images in a way that works with HUGO. If not, let me know, maybe I can figure something out. I've been setting "Create a folder for each post?" to "no", which sounds closer to what you want.
Thanks again, your data has been very helpful, and also I understand if you've moved on, totally fine. :)
@lonekorean you're the best.
I'm going to try it now.
I think it works like a magic, there are so many images that were "unavailable" before your last commit, now it seems to be ok.
I'll test some way to upload images for new content using the same file/folder structure for the import (images inside each post) if not possible I can create conditions on my template to migrate the old content and be ready for the new content. (images download still in progress and it will take a long time due to my bad connection here in the mountains).
The change of markdown parser is cool, again, you are the best.
My big problem now is how I can separate the dual-language post strings created while we're using a plugin in WordPress. I'm thinking of a way to duplicate the content then clean up a language for English content, export only one language, and repeat the task with the second language. (really big time consuming).
I experimented with a way to split the languages apart in another branch: https://github.com/lonekorean/wordpress-export-to-markdown/compare/file-lang-split
It flows like this:
- if there are no pt/en tokens, just write a post file as normal
- if there are pt/en tokens, write 2 files, one with the pt content and the other with en content.
- sometimes there is pt content but no en content, in which case only write a pt file
I'm not sure exactly how you wanted the output to be shaped, but maybe that's one approach you could work with.
Also this code is VERY hacky and makes some assumptions. ๐ Your problem seems to be very specific, so I was not intending to merge and publish this code.
I'm going to go ahead and close this since the original issue is resolved.
Thank you for sharing your data with me and working with me!
I look forward to seeing the final result. ๐