ZenphotoCMS Forum
dynamic image resize - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: dynamic image resize (/thread-6073.html)



dynamic image resize - vsPiotr - 2009-11-03

Hi All,

Is it possible to set up a theme to set the max width/height of the images based on screen size?

I just don't want to do any page reloads so I guess if the size is gathered at album/index.php and passed to image that would be ideal.

Any suggestions?




dynamic image resize - vsPiotr - 2009-11-03

progress:
I tried some AJAX (grabbed from tutorial, I don't really know what I'm doing exactly)
`
///AJAX TESTING

function getXMLHttp(){
  var xmlHttp
  try{
    //Firefox, Opera 8.0+, Safari
    xmlHttp = new XMLHttpRequest();
  }
  catch(e){
    //Internet Explorer
    try{
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e){
      try{
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e)
      {
        alert("Your browser does not support AJAX!")
        return false;
      }
    }
  }
  return xmlHttp;
}

function MakeRequest(){
  var xmlHttp = getXMLHttp();

  xmlHttp.onreadystatechange = function(){
    if(xmlHttp.readyState == 4){
      HandleResponse(xmlHttp.responseText);
    }
  }

  xmlHttp.open("GET", "/customImage.php", true);
  xmlHttp.send(null);
}

function HandleResponse(response){
    document.getElementById('image').innerHTML = response;
}

So essentially I'm executing customImage.php which contains:

`
but I get undefined function errors.

at a loss again.

P.




dynamic image resize - acrylian - 2009-11-03

I can't help specifially but you can get the pure screensize values via JS and surely with more conventient JS frameworks like jQuery. You will have to do some research.

Genereally I would recommend to use the viewport size (browser window) and not the screensize. If someone has a big screen that does not necessarily mean he browses full screen (mac users do rarely as there is not real full screen mode). The bigger the screen the bigger the chance that the users shares the screen with several programs at the time.




dynamic image resize - sbillard - 2009-11-03

Please also look at the viewer sized images plugin. It will give you an example of how to resize the images without a page reload. You would, of course, have to figure out what size to resize to.




dynamic image resize - vsPiotr - 2009-11-05

Thanks guys! That definitely points me in the right direction




dynamic image resize - vsPiotr - 2009-11-05

Hi,
for the curious, I did get it to work using jQuery to basically append w & h of my "content" element to all the thumbnail "li" links and from there I used
printCustomSizedImage("alt",NULL, $_GET['w'], $_GET['h']).

I do a bit more checking before the image so that if the w and h can accommodate the default size then it prints that.
here's my jQuery:
$(document).ready(function(){ $("li a").each(function() { this.href += "&w=" + $("#content").width() + "&h=" + $("#content").height(); }); });