RafidMuhymin / astro-imagetools

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

Plugin changes IMG src #50

Open ClintH opened 2 years ago

ClintH commented 2 years ago

Platform: Windows astro-imagetools: 0.6.3 astro: 1.0.0-beta.27 node: 18.1.0 npm: 8.8.0

Hi!

astro-imagetools messes with IMG sources, even when it's not being directly used.

In an .astro front-matter, I have: import test from '/src/images/test.jpg';

and below in the HTML: <img src={test}>

When running with npm run dev, the IMG src is set to /assets est@2880w.32f1e65e.jpeg

I would not expect astro-imagetools to mess with the src when a regular IMG element is being used. If I take the plugin out of the integrations list in astro.config.mjs, the IMG src is /src/images/test.jpg, and works as intended.

RafidMuhymin commented 2 years ago

You are correct @ClintH ! astro-imagetools parses the image imports and generates assets for them. It doesn't know whether you will use them with <img> elements, or components, or if you will use them at all.

RafidMuhymin commented 2 years ago

And this file naming issue (assets est instead of assets/test in /assets est@2880w.32f1e65e.jpeg) has been fixed in astro-imagetools@0.6.4

IanVS commented 2 years ago

The parsing in windows might still not be correct, according to https://discord.com/channels/830184174198718474/855126849159954492/982140603037016094 on discord. We can use https://github.com/rnwolf/astro-throughputfocus-com/blob/main/src/pages/posts/someblogpost0.md as a reproduction.