Fresh install of D7.15, fresh Omega 3.x subtheme, FlexSlider 2.x-dev.

all image styles and default thresholds render except for 1382. When Omega kicks in the 1200px grid (meaning the browser window is at least 1220px wide), and the browser window is > 1382 px, the 992 image style is still being rendered.

My attempt at a workaround: Created new image styles and set custom thresholds:
image_style[size]:threshold set @ admin/config/media/ais =>240:360, 480:480, 768:768, 1024:1024, 1200:1200.

One thing I noticed, when first enabling (ticking the "selected" box for the style @ admin/config/media/ais) for my custom image styles, the module pre-populates a threshold that is different than the image style size. EX: 240:360, 480:500, 768:800, 1024:1200, 1200:1440. Keeping these "default" thresholds or making them correspond (480:480, 768:768, 1024:1024, 1200:1200) doesn't "fix" the issue.

When the browser window ($(window).width();) is well above the threshold size for 1024 [or 1382 for default ais_image_style] the images are not being replaced.

Screenshot: http://d.pr/i/2Ijc : Custom imagecache_actions text overlay that displays the preset name on the image [not to mention you can tell because the image is "blurry" as it's been scaled up by FlexSlider] so you know which style is loaded.

Dev URL: http://cndemo.dev4.webenabled.net

I was initially thinking that only the first three image_styles set with a threshold were being rendered. I disabled threshold-480, expecting that 1382 would then work, but it didn't. I will be doing a demo presentation at a meetup group in Chicago tonight, and while I'll still be showing how AIS "works" with responsive slideshows like Flexslider, it is not working 100% or as fully intended.

Please, lets fix this bug, as the ais module is invaluable and has the simplest UI for my Drupal-savvy clients.

Thanks,
Erik

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

spotzero’s picture

Actually, it will, but you'd need a very high-res screen get to see it ;)

To understand what's going on, we need to look at how AIS decides the size of the browser. Since browsers on mobile devices are pathological liars, this unfortunately has to be done in a complex (as originally described: https://drupal.org/node/1467216#comment-5744952).

By default, AIS picks the size as the minimum of the following:

window.outerWidth, window.screen.availWidth, $(window).width(), window.outerHeight, window.screen.availHeight, $(window).height().

The results of which, in firefox maximised on a 1080p screen are:

[1920, 1920, 1904, 1033, 1080, 915]

The selected size is then 915, which is less then 992 and greater than 768, so threshold-992 is selected.

Since you're only showing landscape images (on your demo site), you probably don't want browser height considered when AIS is selecting sizes. To adjust this, go to the AIS config page (admin/config/media/ais) and set "Threshold Determination Method" to "Width".

Good luck on your presentation!

spotzero’s picture

Status: Active » Needs work

Hmm, except that your demo site does have Threshold Determination Method" to "Width" . . .

That is a problem...

spotzero’s picture

Status: Needs work » Needs review

Fixed in dev.

It was a Javascript bug.
"1382" > "992" = false
1382 > 992 = true

spotzero’s picture

Two problems fixed and pushed to the dev branch.

1. The sizes of styles were being compared in JavaScript as strings. Hence "1382" is less than "992" because "9" is greater than "1". I've used the JavaScript Number() function make sure that sizes will always be compared numerically.

2. The style size selector JavaScript doesn't pick the most appropriate style if the list of styles aren't ordered by size. I've added the necessary code to sort the styles before they are added to the JavaScript.

BLadwin’s picture

Status: Needs review » Reviewed & tested by the community

Presentation Successful! Module Patches Successful!

Thanks for taking the time yesterday to help me out. While presenting, I didn't realize that the max resolution of the projector was 1024px in width; I had to use my image presets to reproduce the bug I encountered. I'm really glad that you were able to be prompt in your response. I really enjoy the fact that the audience at the meetup was able to see how awesome the contrib-space maintainers are. I <3 Drupal and love being a part of it.

Just to clarify your last statement: Are you ordering the image_styles based on numeric value only in Drupal.settings.ais? Would a weight field be better, utilized in the admin UI for AIS?

Thanks for the great work. I can confirm that everything is now working as intended.

minorOffense’s picture

I tested the latest code in the repo. Seems to work just fine. I'd say RTBC.

spotzero’s picture

Status: Reviewed & tested by the community » Fixed

Tagged release 1.4.

The ordering is by threshold size, but it only needs to be sorted this way for the JavaScript code to work well.

It could be problematic to have the admin ui sorted this way since the threshold size is configurable. While configuring your style thresholds, they'd move around in the list, which makes for an unpleasant ui.

I'm happy to hear your presentation went well and thank you for all of your feedback.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

robertom’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
Status: Closed (fixed) » Needs review
FileSize
627 bytes

Sorry for my bad english.

I would reopen this bug, becouse I think this isn't fixed...

I have this image style checked as adaptive image style:

site-threshold-479 (image style width: 320px) & threshold value is 479
site-threshold-767 (image style width: 480px) & threshold value is 767
site-threshold-959 (image style width: 747px) & threshold value is 959
site-threshold-9999 (image style width: 940px) & threshold value is 9999

currently when windows size is (i.e.):

1) 400px, cookie has site-threshold-479 value (image width 320px)
2) 600px -> cookie has site-threshold-479 value (image width 320px stretched to 480px)
3) 800px -> cookie has site-threshold-767 value (image width 480px stretched to 747px)
4) 1100px -> cookie has site-threshold-959 value (image width 747px stretched to 940px)
5) "Infinity" -> cookie will have site-threshold-9999 value (image width 940px)

seems to me that only first case is correct...

I have fixed this problem with the attached patch...

What do you think about that? Anyone can reproduce this bug?

spotzero’s picture

Status: Needs review » Postponed (maintainer needs more info)

Hey Roberto,

First, thank you for that patch.

I had a hard time wrapping my head around the problem you describe, so I rewrote your description, but I removed the specifics of the images styles, since AIS just selects them (AIS doesn't care what size of image they actually generate), and I've renamed the images styles to get rid of all the numbers.

So, here's what your AIS styleset looks like:

Image Style => Threshold
ALPHA => 479
BETA => 767
GAMMA => 959
DELTA => 9999

And here's the reaction you reported:

Window Size -> Image style that AIS selected:
1) 400px -> ALPHA
2) 600px -> ALPHA
3) 800px -> BETA
4) 1100px -> GAMMA
5) "Infinity" -> DELTA

Technically, the above is correct. But I think I understand your issue now.

Currently, AIS selects the style with the largest threshold, that is smaller than the window size. With a specially case if the window size is smaller than the smallest threshold.

This graphic shows how AIS currently picks a image style based on size:

Window Size:         (1)          (2)            (3)    (4)                         (5)
Thresholds:   <----------479---------767-----------959-------------9999-------------------->
Image styles:                ALPHA    |  BETA       |   GAMMA        |  DELTA

If I understand correctly, your patch would make AIS select the image style with smallest threshold larger than the window size, and would move the special case to the end. Which makes the the graphic to look like this:

Window Size:         (1)          (2)            (3)    (4)                         (5)
Thresholds:   <----------479---------767-----------959-------------9999-------------------->
Image styles:    ALPHA    |  BETA     |   GAMMA     |  DELTA

Please let me know if this is your issue.

robertom’s picture

Status: Needs review » Postponed (maintainer needs more info)

Hi spotzero, thanks for your rewrite of my (intrigued) description ;)

If I understand correctly, your patch would make AIS select the image style with smallest threshold larger than the window size, and would move the special case to the end. Which makes the the graphic to look like this

Window Size:         (1)          (2)            (3)    (4)                         (5)
Thresholds:   <----------479---------767-----------959-------------9999-------------------->
Image styles:    ALPHA    |  BETA     |   GAMMA     |  DELTA

Exactly. This is what I expect from the example in the description of the project:

Example:
If there are three image style selected, with thresholds of 480, 768, and 992. If the window width is from 0 - 480 pixels, the adaptive image will be displayed using the image style with a threshold of 480. From 481 - 768, the 768 image style will be used, and any wider than 769, the image style with the threshold of 992 will be used.

(I think) the patch respect this behaviour...

EDIT:

The graphic look like correct to me, but I'm in doubt for the sentence (due to my lack of english comprehension)

If I understand correctly, your patch would make AIS select the image style with smallest threshold larger than the window size, and would move the special case to the end.

my patch considers the threshold as a "right limit" of an interval

0-479
480-767
768-959
960-9999 (or infinity)

robertom’s picture

Status: Postponed (maintainer needs more info) » Needs review
spotzero’s picture

Assigned: Unassigned » spotzero
Status: Postponed (maintainer needs more info) » Needs work

Hmm, you're absolutely right, my code doesn't match my description of how the code works. That is a problem.

I have to also add that your english comprehension seems to be just fine.

I'm a little apprehensive of committing this patch as is, because this changes the way the module actually selects images styles, and thus would be more than a little annoying for people running AIS in production and upgrading.

What I will do however is apply this change in multi-style set branch of AIS (for background, I'm currently working on a update to AIS that allows you to configure multiple sets of adaptive image styles.) Since that update contains some big functional changes already, I don't mind including another functional change like this one.

Peacog’s picture

I wanted to chime in here to let you know that Roberto's patch fixed a problem on my site where threshold-1382 was not kicking in with the latest dev version. Just to be sure I understand the new functionality that you're currently working on, will there be an option to choose which threshold selection method to use, the standard one, or Roberto's alternative?
Thank you both for the great module and the patch.

devad’s picture

D7.22, Omega 3.x , views slider

threshold-1382 adaptive images just disappeared from my views slideshow after upgrading from D7.20 to D7.22 and AIS module from 7.x-1.4 to 7.x-1.6

I have read that AIS+OMEGA 3.x have problems with Tresholds bigger than 1200px.

So, after I have overriden threshold-1382 image style to 1150x1150px (admin, configuration, media, image styles), and edited threshold-1382 ais selected style Treshold to 1150px as well (admin, configuration, media, adaptive image styles), that brought back to my views sider threshold-1382 size.

I hope this will help someone.

morleman@gmail.com’s picture

D7.22, 960/720/mobile Responsive hybrid, Flex-slider w/ views slider 7.3.x

Had the same problem... the AIS would not pick up on the threshold-1382, but as I scaled down the screen size the other thresholds stared to kick in then. I noticed there's an "Adaptive" image style in addition to the other "threshold ones". In investigating my issue, I noticed that under inspect element, the height was defaulting to 555px. To resolve, I pin point that the Adaptive image style was being used. Once I updated the "Adaptive" Image style From 800x 600 to my full screen default of 1280px 400px (scale and crop). It all works fine now with no patch (above).

I hope this helps as well.

FMB’s picture

#9 implements the behaviour I expected from this module according to its description:

If there are three image style selected, with thresholds of 480, 768, and 992. If the window width is from 0 - 480 pixels, the adaptive image will be displayed using the image style with a threshold of 480. From 481 - 768, the 768 image style will be used, and any wider than 769, the image style with the threshold of 992 will be used.

vistree’s picture

Hi, old thread - but still valid ;-) For me patch in #9 is also the logical solution to work with AIS. Expecially with the presets installed with AIS does this pathc make totally sense. Otherwise my images are always "to small". Can't this be added to core?