Everything worked fine untill I made a @foreach. I have added max-width: 100% to the image class but still no success. Only the first image is being rendered.
What I'm trying to accomplish to is always hide the product images with a display: none. But apparently, all the images that has a display: none is not rendered.
Would the checkResponsiveImages help with that issue? I just read it but I can't seem to figure out if it's the solution.
Does it make any difference if the "max-width: 100%" is put directly on the image tag?
<img style="max-width:100%" src"......" ...>
Do you use a 3rd party javascript library to run the image transition when you choose colors? If yes, you might need to run Slimmage.js before the other library.
The problem occurs when the page is loaded and both images are shown.
I wan't to hide all .categoryImage containers except the first one.
The first one is shown through Javascript categoryImage.first().show(); but the rest of the images has a display: none;
This display: none; makes the src disappear on the images.
If the images are the same dimensions, maybe you could play with the z-index, rather than the "display".
I think setting display:none, hits problems with the browser not calculating the image width (and that the browser chooses not to load the image), and thus not being able to set a max-width attr on it.
I ended up using a bit of, well.. Bad code to fix it but this is how I solved it:
Each image AFTER the first image becomes absolute underneath the first image.
When you hover the color choice, each of the .categoryImage containers gets a class called .active. This class makes the images static which solves the problem:
No Src tag
Everything worked fine untill I made a
@foreach
. I have addedmax-width: 100%
to the image class but still no success. Only the first image is being rendered.Live example can be seen here if you hover one of the color choices.
My foreach looks like this:
It works fine if I use
"@img.GetCropUrl("product image")"
Alright I found out it's because theres a
display: none
on the.categoryImage
which somehow makes the plugin miss the source.Do you guys have any suggestion as to how I can use
display: none
and make the plugin work?Depending on what you are doing you will likely need to use the checkResponsiveImages method, check the Slimmage JS documentation here
Hey Jeavon,
Thank you for the response!
What I'm trying to accomplish to is always hide the product images with a
display: none
. But apparently, all the images that has adisplay: none
is not rendered.Would the checkResponsiveImages help with that issue? I just read it but I can't seem to figure out if it's the solution.
Does it make any difference if the "max-width: 100%" is put directly on the image tag?
Do you use a 3rd party javascript library to run the image transition when you choose colors? If yes, you might need to run Slimmage.js before the other library.
Hey Tommy!
Sadly that doesn't work either. As soon as the
Display: none
is applied the image src disappears.The priority of my scrips are:
The Javascript I use for the color choices are this:
You might be better not using the .hide() method in your jquery, but manipulating the style attribute directly by using:
http://api.jquery.com/attr/
Or you could have a new class, called ".not-active", and append that to your hidden elements.
And use some other CSS magic to hide your elements.
Hey Paul!
The problem occurs when the page is loaded and both images are shown.
I wan't to hide all
.categoryImage
containers except the first one. The first one is shown through JavascriptcategoryImage.first().show();
but the rest of the images has adisplay: none;
This
display: none;
makes the src disappear on the images.Maybe this video can illustrate it better than I can explain: https://youtu.be/MdJHR32PVXU
:o)
Hi Mike
If the images are the same dimensions, maybe you could play with the z-index, rather than the "display".
I think setting display:none, hits problems with the browser not calculating the image width (and that the browser chooses not to load the image), and thus not being able to set a max-width attr on it.
Thus slimmage cant give the element a "src" attr.
Ah that makes sense Paul!
I ended up using a bit of, well.. Bad code to fix it but this is how I solved it:
Each image AFTER the first image becomes absolute underneath the first image.
When you hover the color choice, each of the .categoryImage containers gets a class called .active. This class makes the images static which solves the problem:
Thanks for the inputs, help and brainstorming guys, I really appreciate it!:)
is working on a reply...