patronage / bubs-next

Headless Wordpress + Next.js Project scaffolding
https://bubs-next.vercel.app
MIT License
37 stars 10 forks source link

Extract inline images and so we can control the render of images/srcset #8

Open ccorda opened 4 years ago

ccorda commented 4 years ago

A Gatsby plugin exists with some nice benefits: https://www.npmjs.com/package/inline-images-plus-code

ccorda commented 4 years ago

Broke the link part out to it's own issue #11. Updating title here to make this just about images.

ccorda commented 3 years ago

This is also an option: https://github.com/Quartz/wp-graphql-content-blocks

kylehotchkiss commented 3 years ago

We'll also need to support plain posts / pages. What do you think about processing the WYSIWYG with a library like this: https://www.npmjs.com/package/html-to-react and then converting Images to along with the link processing in https://github.com/patronage/bubs-next/issues/11 ?

I've worked with html-to-react before, and it appears somewhat commonly used with 600k downloads a week. I don't think it'd take too long to implement it, the caveat is that the syntax in html-to-react is a little odd (it looks like Java code) but I could keep it in a library/ file so it's not a distraction

ccorda commented 3 years ago

I don't have a strong opinion on a server-side approach on the graphql side, or by doing it in React/JS. Whichever is more reliable.

One thing besides images and links we should aware of is shortcodes, e.g. someone saving a youtube link and how we might handle that.

ccorda commented 3 years ago

How Gatsby approaches this: https://github.com/progital/gatsby-wpgraphql-inline-images

kylehotchkiss commented 3 years ago

This is built into Next.js' <Image> component:

https://nextjs.org/blog/next-11#image-placeholders

Can be enabled with placeholder="blur"

ccorda commented 3 years ago

This issue isn't about lqip (that one is #110) -- this is about parsing markup of a WYSWIYG and actually rendering images. We do have a beat on this from a recent project.

ccorda commented 2 years ago

shortcode example that uses WP's shortcode lib: https://github.com/TallerWebSolutions/wordpress-classic-parser/blob/main/src/Parser.ts