Click here to Skip to main content
15,885,767 members
Articles / Web Development / ASP.NET

Dealing with Images in Content Management Systems, Part 1

Rate me:
Please Sign up or sign in to vote.
4.95/5 (124 votes)
17 Feb 2009CPOL23 min read 425.1K   3.1K   457  
Browser-based resizing and optimisation of images

function setViewportDimensions(hiddenFieldID)
{
    var field = document.getElementById(hiddenFieldID);
    var width;
    var height;
    
    // see http://evolt.org/node/30655
    
    if (window.innerWidth)
    {
	    width = window.innerWidth;
	    height = window.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientWidth)
    {
	    width = document.documentElement.clientWidth;
	    height = document.documentElement.clientHeight;
    }
    else if (document.body)
    {
	    width = document.body.clientWidth;
	    height = document.body.clientHeight;
    }

    field.value = width + "," + height;
}

var thumbnailDivs = {};

function registerThumbnailDiv(thumbnailDivId)
{
    thumbnailDivs[thumbnailDivId] = document.getElementById(thumbnailDivId);
    thumbnailDivs[thumbnailDivId].style.visibility = "hidden";
}

function hideThumbnailDivs()
{
    for(var divId in thumbnailDivs)
    {
        thumbnailDivs[divId].style.visibility = "hidden";
    }        
    document.onclick = null;
}

function showThumbnailDiv(thumbnailDivId)
{
    hideThumbnailDivs();
    thumbnailDivs[thumbnailDivId].style.visibility = "";
    window.setTimeout("document.onclick = hideThumbnailDivs", 300);
}   

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United Kingdom United Kingdom
Tom Crane is a software developer from London. He likes to code in C# but has been known to implement Java-based content management systems for public sector clients.

Most of the time he does web programming and tries to make complex tasks seem easy through friendly UI.



Comments and Discussions