26

Re: Auto resize images

hmmm, ....so what is "Litebox" ? Another xxxxbox big_smile

Re: Auto resize images

I find highslide better, but that is personal.

28

Re: Auto resize images

When I looked at Highslide and Thickbox?, I would have said they were more intensive, rather than faster than Lightbox or Greybox. That's just be my personal opinion, though.

29

Re: Auto resize images

Tjalve,

I have to come back to this - your mod works wonderful this far, but I encountered a small problem.
If somebody insert an image with that tag, which is smaller that my preset width, it get resized to that width and of course distorted.

Is there a way to tell - lets say: "if the image is largen than 680 px width, than resize - if it is smaller, keep the original size"

Thank's

30

Re: Auto resize images

I have found a solution!
I combined Tjalve's script and the script out of the "add Lightbox" Mod from http://www.punres.org/desc.php?pid=282 by Robert h

Now I can set the max width for images to be shown with the img_tag

If wider than my postarea it will be displayed resized with a link to be opened in original size - or (if set) with Lightbox
If smaller or exactly as my postarea it will be displayed in original size.

And, if using Lightbox, you can set the max width of the image to be opened with Lightbox - lets say bigger than 800 pixel width has not to be displayed with Lightbox, but resized and with a link to be opened in original size....

Replace the original img_tag in parser.php with this. If not using Lightbox you have to delete the Lightbox parts in this mod.

// ************************************************************************************************************************************* //
//********************** MOD extra Image Tag for bigger Pictures *****************//

function handle_img_tag($url, $is_signature = false)
{
    global $lang_common, $pun_config, $pun_user;

    $img_tag = '<a href="'.$url.'" onclick="window.open(this.href); return false;"><'.$lang_common['Image link'].'></a>';

    if ($is_signature && $pun_user['show_img_sig'] != '0')
        $img_tag = '<img class="sigimage" src="'.$url.'" alt="'.htmlspecialchars($url).'" />';
        
        
else if (!$is_signature && $pun_user['show_img'] != '0')
{
    if (@fclose(@fopen($url, "r")))
    {
        $imagehw = GetImageSize($url);
        $width = $imagehw[0];
        $height = $imagehw[1];
        $img_tag = '<center><img class="postimg" src="'.$url.'" alt="'.htmlspecialchars($url).'" /></center>';
        
    if ($width > 680) //+++ this is your desired max width of images - also to be set inside the img_tag +++++++++++++++//
    {
    
//+++++ img_tag with Lightbox  - delete if not using Lightbox +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//

        $img_tag = '<center><a href="'.$url.'" rel="lightbox"><img width="680" class="postimg" src="'.$url.'" alt="'.htmlspecialchars($url).'" /></a></center>';
        
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//    


   
//+++++ without Lightbox ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
        //$img_tag = '<center><img width="680" class="postimg" src="'.$url.'" alt="'.htmlspecialchars($url).'" /> <br> This image has been resized, click <a href="'.htmlspecialchars($url).'">here</a> to view the full-sized image.</center>';  
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//    

}


//++++++++++ you can use this to set a width limit for images to be show with Lightbox - delete if not using Lightbox +++++++++++++++++++//    

        if ($width > 800) //+++ max. width of images to be show with Lightbox - wider images will be shown resized and with link ++++//
    {
        $img_tag = '<center><img width="680" class="postimg" src="'.$url.'" alt="'.htmlspecialchars($url).'" /> <br> This image has been resized, click <a href="'.htmlspecialchars($url).'">here</a> to view the full-sized image.</center>';
}
    
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//    

    
    }
    else
    {
        $img_tag = '<strong>error: image ' . $url . ' cannot be loaded.</strong>';
    }
}            
        return $img_tag;
}

// ******************************************************************************** //
// ************************************************************************************************************************************* //

31 (edited by AndyDeacon 2007-11-05 21:16)

Re: Auto resize images

no64

Your code doesn't work.

error: image http://www.ndesign-studio.com/file/wall … 80x800.jpg cannot be loaded.

32

Re: Auto resize images

well, yes and no :S   ....the problem is the "fclose" and "fopen" which is included in the original code of the Lightbox integration mod. Your server has to support that  - php.ini fopen has to be set to "on"

I recognise the same problem with this when I was changing the server, but after talking with my hoster and changing the settings it worked again.

Maybe somebody else has a better solution for not using "fopen" and "fclose".

Btw. Your Blog looks great, did you made the theme by yourself?
Could you tell me what plugin you use for the "links" page and for the "contact" page, please?

Re: Auto resize images

The code from 1st page is working!

34

Re: Auto resize images

you mean tjalves code?
Yes, of course, that one just changes the img tag and "my" code is a combination of that code and a lightbox integration....

...and the code from the lightbox integration doesn't work if your server don't have those setting to allow "fopen" and "fclose"

35

Re: Auto resize images

why not do it via css? find the part that out puts the img
add class
go to css set height and width... of that class.

so no matter how big it will only display the set height and width.

i did that when i made a simple address book system small db to sql  with contact images....


Q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

36

Re: Auto resize images

yes, but what is if the image is smaller thant set in the CSS - is it going to be scaled up?

37

Re: Auto resize images

yes it will be ... hummmmm....

someone could always write a if then or else statement for file size.... to link it to a css.

oh well just a thought.
q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

38

Re: Auto resize images

..what about this:
http://www.punres.org/desc.php?pid=358

Haven't testet it yet, but it may be useful for certain purposes