-
-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image URL as a web component attribute #162
Comments
so you have something like <my-el img="./path/to/file.jpg"></my-el> does the file get copied over? |
Yes. Though in my case it data from markdown front matter, and the data is absolute from root.
and my njk template is like this <my-el image_url="{{ image_url | url }}"></my-el>
<img src="{{ image_url | url }}"> The img element is correct with the file copied and renamed, and my-el is... <my-el image_url="/foo/bar.jpg"></my-el>
<img src="../xxxxx.jpg"> |
So, I tried what you may be hinting, using <my-el src="{{ image_url | url }}"></my-el>
<img src="{{ image_url | url }}"> Similar result, but now also have reference errors. <my-el src="/foo/bar.jpg"></my-el>
<img src="../xxxxx.jpg">
|
ah so you use it in two places <!-- a custom tag will not be checked or modified -->
<my-el image_url="{{ image_url | url }}"></my-el>
<!-- this will find the image and copy/hash and adjust this src -->
<img src="{{ image_url | url }}"> so if you only use now if you were to put the image into <my-el src="{{ image_url | asset | url }}"></my-el> then I think it should work as all Ideally, you would be able to adjust which tag and which attribute gets defined as an asset... but that API is currently not there 😅. |
Thank you for the clarification. Maybe, for rollup-plugin-html... params.extractAssets: boolean | { tag: string, attributes: string[] }[] Case statements in the plugin src might be preceded by a params.extractAssets.forEach It a minor issue for me now, so I'm monkey patching attributes in my _site files. |
Pull request modernweb-dev/web#1541 submitted. The request is intended to close this issue (and save me from monkey patching my _site files). |
My web component takes an image URL as an attribute. In dev mode, all works perfectly. But, Rocket build renames the image URL, and does not update the web component's attribute. Is there a filter to update the image URL? Or a configuration to pass through images without changing the URL?
The text was updated successfully, but these errors were encountered: