RafidMuhymin / astro-imagetools

Image Optimization tools for the Astro JS framework
astro-imagetools-docs.vercel.app
MIT License
407 stars 44 forks source link

Allow Returning Raw Data Instead of HTML #150

Open amxmln opened 1 year ago

amxmln commented 1 year ago

Hello there! I’m currently looking into using astro-imagetools to implement my own <Img /> and <Picture /> components in Vue.js.

This should be possible by using the API functions, but unfortunately the values are returned as HTML. I could parse those return values and get my data that way, but I think it would be nice to provide some additional API functions to just return the data itself, so a user can decide how they want to build the HTML from it.

Something like getRawPicture(props) that returns an array of sources, the placeholder image, image dimensions, etc.

RafidMuhymin commented 1 year ago

It's on my roadmap but I currently don't have time to work on this. If you are interested you can create a PR. getImage() sounds better to me. The initial thought was to export the internal getImage() utility after tweaking a little bit.

amxmln commented 1 year ago

Yeah, that’s what I thought would be an option as well. What would you want to tweak about the function?

Totally get not having enough time to work on it—you‘ve done so much already!

I can’t commit to a PR right now, but I’ll look into it and update the issue accordingly.

RafidMuhymin commented 1 year ago

Happy to see your interest in the project.

What would you want to tweak about the function?

Can't tell currently. Will have to check. I just said because it might need tweaking.