开发者

Layout fix with images rendered via dynamic image handler

I am using a httphandler to dynamically resize images that are rendered on a page. I have a preset width that all images must confirm - and the height of the images can vary (proportions constrained to the original width and height). I am caching the images - however, when they are originally loaded, the httphandler is called after the page is rendered - so for longer images - sometimes on intial load, layout breaks with larger images as they overlap the content that is below it. Here is an example screenshot from here http://www.teakmonkeystudios.ca/photos/photo.aspx?id=10801:

Layout fix with images rendered via dynamic image handler

Here is the css:

.gallery
{

    margin-left:0px;
    padding-left:5px;
}


ul.gallery div.top_frame
{
       width:732px
}


ul.gallery div.view_frame
{
    margin-left:5px;
}

ul.gallery div.image_frame
{
    border: 1px solid #dddddd; padding-top: 5px; height:100%; min-height:490px;
    padding-bottom: 5px; text-align: center;
}

ul.gallery div.button_frame
{
    width: 732px; text-align: right; margin: 4px 0px 0px 0px;
}


ul.gallery div.name_frame, ul.gallery div.original_name_frame
{

    开发者_如何学Gomargin: 0px 0px 0px 5px;
}

ul.gallery div.name_frame h2
{
    margin: 2px 0px 3px 0px;
    padding: 0px;

}

ul.gallery div.date_frame
{
    margin-left:5px;
    margin-bottom:5px;
}

ul.gallery div.update_frame
{
    width: 732px; margin-bottom: 5px; margin-top: 5px;text-align:right;
}



ul.gallery div.desc_frame
{
    margin-left:5px;
    background-color:#eeeeee;

}

ul.gallery li
{
     width: 732px;

     display: -moz-inline-stack;
     display: inline-block;
     vertical-align:top;
     margin: 5px;
     zoom: 1;
     *display: inline;
     _height:100%;
      color:#000000;
      letter-spacing:0px;
      line-height:normal;

} 

ul.breadcrumbs li
{
    float:left;

    margin:0px;
    padding:0px;
    width:100%;
}

ul.breadcrumbs li a
{
    font-size:12px;
}

Since the image in the screenshot below may be cached you may not see the broken layout. I wonder if rendering the images in a table would be better? Or is there a css fix? I've even tried Jquery and used document ready to adjust the height of the image containers - but the image may not be loaded - so I can't return the height of the image in the function. Any suggestions on how to solve this issue?


If your images are all going to be the same width, output the IMG tag with a width attribute. this may help.

<img src="..." width="720">

Using input type="image" for this type of application is a bit odd. Why not just use an A-tag wrapped around an image?


This is the key to your problem:

however, when they are originally loaded, the httphandler is called after the page is rendered

An IHttpHandler sees the request before the response is sent to the browser and can do whatever it needs, including responding with a resized image. I'm doing that a lot, never had a problem. Since it doesn't work for you, I'm 100% you've got a bug in your HttpHandler.


If i create the image and load it into the cache in the custom image's prerender event - it seems to have fixed this issue. Originally the control rendered the image info to the src string in the browser and the image was then intercepted by a httphandler that calls a cachemanager (if exists - return, if not - create). Since the problem above seemed to happen only when the image was initially created - I figured recreating it before it was 'requested' may help - and it appears it has. If there are consequences to this - I will edit my solution.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜