hexojs / hexo-migrator-wordpress

WordPress migrator for Hexo.
http://hexo.io/docs/migration.html
MIT License
48 stars 29 forks source link

Migrated posts dont preserve image attributes #108

Open jashsayani opened 4 years ago

jashsayani commented 4 years ago

Wordpress composer lets you set images to float left, right or be centered in the post. Migrated posts always center the images instead of respecting image attributes set on the image in wordpress.

Original posts:

Screen Shot 2020-09-05 at 10 14 38 PM

Migrated result:

Screen Shot 2020-09-05 at 10 14 46 PM
curbengh commented 4 years ago

When migrating the articles, the original <img> will be converted to Markdown, stripping its attributes in the process. After migration, it's up to the theme how to display the image.

While it's possible to style the image without using custom class, but if you need to add it, you can use the filter API to insert it.

jashsayani commented 4 years ago

If the attributes are stripped while conversion, how will the theme know how it was set in wordpress? The attributes should be preserved, so images can be floated left or right.

adnan360 commented 4 years ago

Unfortunately, there is no way of doing this on plain markdown. We'd have to use HTML instead to make it work on Hexo side. We can have a parameter to retain these attributes.

There are plugins to achieve this. But as far as I've looked, they are complicated to use and not portable (if we need to use the markdown outside of Hexo for example they would need further processing). Optional parameter to include HTML with attributes would be a great balance I think.

The attributes should be preserved, so images can be floated left or right.

I think WordPress adds a ton of attributes to images. Can you list some attributes, other than alignment, that you are interested in? It will help us determine how we can solve this.