views:

45

answers:

1

Hi there,

I am using ExtJS for my project.

I need to create a window in ExtJS of variable size to display an image my user has uploaded.

But, if a smaller image say 150x150 is uploaded, I want the window to "fit" the image, i.e., the window should be 150x150.

But if a larger image, say 3000x3000 is uploaded, then I want the window to be only 800x600, with the image properly resized and rendered inside it.

I want to do this in ExtJS. Here's my code for the image viewer. Please help me find a solution here.

    viewWin = new Ext.Window({
          title : title,
    layout  : 'auto',
    width   : '50%',
       resizable: false,
    shadow  : true,
    items   : [new Ext.ux.MediaPanel({
            border  : false,
            style   : {width:'100%', height:'100%'},
            mediaCfg : {
                mediaType: 'JPEG',
                url :  url,
                }
        })]
});
A: 

To do so, why not use shadowbox : Shadowbox

I think it's the simplest way, it automatically fits the user resolution and image size. It has been adapted for lot of frameworks including Ext, so if the use of such a tool is not a problem for your project, I would highly suggest so ;)

Michael Lumbroso
Hey! Even I landed on Shadowbox myself in the meantime.. Thanks for your help.
Hrishikesh Choudhari