Fit an image perfectly in html() dimensions?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Fit an image perfectly in html() dimensions?

Post by highend »

I have an animated.gif that I want to preview via the inbuilt html() command

Does anybody know how to put that inside the html code so that I don't need arbitrary values for html() width and height?

Ofc the scrollbars must be hidden...

Code: Select all

    $dims   = property("#image.dimensions", <curitem>);
    $width  = gettoken($dims, 1, " x ", "t");
    $height = gettoken($dims, 2, " x ", "t");
    $src    = replace(<curitem>, "\", "/");
    $file   = gpc(<curitem>, "file");

    // CSS styles
    $cssStyles = <<<>>>
        body {
          overflow: hidden;
        }
    >>>;

    $html = <<<>>>
    <html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <style>
            $cssStyles
        </style>
    </head>
    <title></title>
    <body>
        <div style="position:absolute;left:0px;top:0px">
            <img src="$src" alt="$file" width="$width" height="$height"></img>
        </div>
    </body>
    </html>
>>>;
    html($html, $width + 40, $height + 100, self("base"));
One of my scripts helped you out? Please donate via Paypal

mazot
Posts: 42
Joined: 20 Apr 2020 23:19

Re: Fit an image perfectly in html() dimensions?

Post by mazot »

I am not an expert in HTML but have you tried percentages(%).

klownboy
Posts: 4109
Joined: 28 Feb 2012 19:27

Re: Fit an image perfectly in html() dimensions?

Post by klownboy »

Hi highend, have you taken a look at TheQwerty's HTML Image Preview script viewtopic.php?f=7&t=13690? I know he must do some sizing of the GIF files within that script.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

Post Reply