-
Notifications
You must be signed in to change notification settings - Fork 154
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
[Bug]: Really odd behaviour with image_url output as 'data-...' attribute on Shopify theme dev server #2240
Comments
Same here after upgrading to Shopify CLI v3.47.0 |
@karreiro This might be related to a recent change? |
Same for me. I suppose this is due to recent changes to loading image assets, I never had an issue before that. This liquid snippet:
Will render in local server as:
So the actual image source and data attributes have been removed, and the source is a script asset that only comes later in the code. So there is definitely something fishy here, because not only does this not load the correct src, but it also breaks the html. I have something like this in view-source and you can notice how the image tag loads a script asset that is suppose to come later, picture tag is not closed, closing script tag out of nowhere:
And for reference, this is how the (simplified) liquid looks like in my use case:
|
Same for me I have updated to the latest version 3.47.3 |
Experiencing the same issue here as of the last 24 hours with no changes to CLI version in the project. As part of the debugging process I've tried versions Operating System Shopify CLI version Shell Node version |
Same problem here. Operating System Shopify CLI version Shell Node version Some images are coming back with 404s others are actually coming back corrupted. |
Please confirm that you have:
In which of these areas are you experiencing a problem?
Theme
Expected behavior
Something bizarre is happening with this code when I try and test it locally.
The href tag (url1) will become
//{my-shop-url}/cdn/shop/products/image.jpg?width=1280
However the data-img tag (url2) becomes
http://127.0.0.1:9292/cdn/shop/products/image.jpg?width=720
This url if I try to load it doesn't work, as it appears no CDN urls work in the local test environment and have to loaded from the test site directly.
Yet if I simply print url2 outside of an attribute tag it correctly prints
//{my-shop-url}/cdn/shop/products/image.jpg?width=720
What appears to be happening is the liquid processor, after substituting all liquid tags with their resulting outputs, then runs a kind of hacky 'find and replace' on all instances of
http://127.0.01/
with//{my-shop-url}/
, seemingly in an effort to resolve a recently 'fixed' bug mentioned in these issues (one of which I reported):#2105
#1859
But for some reason it specifically ignores replacing 'data-...' attributes. Using any attribute name other than 'data-...', the url is correctly output.
There seems to be some very questionable code maintenance happening behind the scenes if my assumption is correct, it all seems very hacky to me.
Actual behavior
Verbose output
Reproduction steps
Operating System
Windows 11
Shopify CLI version (check your project's
package.json
if you're not sure)3.46.5
Shell
Windows Command Prompt
Node version (run
node -v
if you're not sure)18.2.0
What language and version are you using in your application?
No response
The text was updated successfully, but these errors were encountered: