Bug with tall thin images (wrong thumbnail)
-
When viewed in slider mode, tall thin images have the wrong thumbnail picked. Test this on smaller browser window heights.
Contest-gallery works out the ‘optimal’ width of the image to pick based on the known dimensions of the image and the known vertical space:
widthCgCenterImageDiv = newHeightImage*widthImage/heightImage;
It then goes on to pick the optimal image based on what thumbnail has minimally higher width than this image:
if(widthCgCenterImageDiv<parseInt(cgJsData[gid].vars.rawData[realId][‘thumbnail_size_w’])){var backGroundUrl = cgJsClass.gallery.function.general.tools.checkSsl(mainObject[‘thumbnail’]);}
else if(widthCgCenterImageDiv<parseInt(cgJsData[gid].vars.rawData[realId][‘medium_size_w’])){var backGroundUrl = cgJsClass.gallery.function.general.tools.checkSsl(mainObject[‘medium’]);}
else if(widthCgCenterImageDiv<parseInt(cgJsData[gid].vars.rawData[realId][‘large_size_w’])){var backGroundUrl = cgJsClass.gallery.function.general.tools.checkSsl(mainObject[‘large’]);}
else{
var backGroundUrl = cgJsClass.gallery.function.general.tools.checkSsl(mainObject[‘full’]);
}However, this is an incorrect calculation. The thumbnail_size_w come from WordPress’s configured thumbnail bounding box sizes. The actual width of thumbnails may be less than this, due to how bounding box thumbnailing works.
You either need to run your computation based on the actual width of the thumbnail (not the config option), or you need to do the “minimally higher” check with constraints both on width and height.
- The topic ‘Bug with tall thin images (wrong thumbnail)’ is closed to new replies.