[ABD] Auto Image Resize 0.0.3 (Non-JavaScript)

Any abandoned MODs will be moved to this forum.

WARNING: MODs in this forum are not currently being supported or maintained by the original MOD author. Proceed at your own risk.
Forum rules
IMPORTANT: MOD Development Forum rules

WARNING: MODs in this forum are not currently being supported nor updated by the original MOD author. Proceed at your own risk.
User avatar
MaidenFan
Registered User
Posts: 43
Joined: Mon Dec 12, 2005 3:33 pm
Location: Aberystwyth, Wales, UK

Re: [BETA] Auto Image Resize 0.0.2 (Non-JavaScript)

Post by MaidenFan »

Right, my apologies, I placed the function outside of one set of curly-braces. To fix the error, just move the whole second-pass function above the last "}" before the end of the file, so the result should look like this:

Code: Select all

    //------------- START IMAGE RESIZE MOD ----------------
    /**
     * Second parse img tag
     */

    function bbcode_second_pass_img($url) {
    
        // [ second-pass function here ]

    }
    //------------- END IMAGE RESIZE MOD ----------------
}
?>
Also replace the "@" before getimagesize() as this suppresses any errors produced by the function (i.e. if the given URL isn't actually an image) which break the site layout.

I've also edited the MOD instructions :).
Personal Site & Blog | Last.fm
erno @ Bash.org wrote:I've lost a machine.. literally _lost_. it responds to ping, it works completely, I just can't figure out where in my apartment it is.
User avatar
JunglistPerfection
Registered User
Posts: 611
Joined: Mon Apr 09, 2007 11:58 pm
Location: Chicago, IL

Re: [BETA] Auto Image Resize 0.0.2 (Non-JavaScript)

Post by JunglistPerfection »

I'll give this another try.
User avatar
JunglistPerfection
Registered User
Posts: 611
Joined: Mon Apr 09, 2007 11:58 pm
Location: Chicago, IL

Re: [BETA] Auto Image Resize 0.0.2 (Non-JavaScript)

Post by JunglistPerfection »

The mod is working perfectly.
Thanks :D

Am I suppose to take @ out or just leave there?
User avatar
MaidenFan
Registered User
Posts: 43
Joined: Mon Dec 12, 2005 3:33 pm
Location: Aberystwyth, Wales, UK

Re: [BETA] Auto Image Resize 0.0.2 (Non-JavaScript)

Post by MaidenFan »

JunglistPerfection wrote:The mod is working perfectly.
Thanks :D

Am I suppose to take @ out or just leave there?
:lol: You had me worried for a minute, I read your post before you edited it.

Leave the "@" in place, it suppresses any errors generated by that function call - if the image isn't found or if the URL points to an invalid image for example. I may implement a proper error-handling feature in future versions, but it serves its purpose for the time being :).

Also, please read the second "important note" on the first page of this topic regarding page load times - I am aware it could have an adverse effect on forum performance.
Personal Site & Blog | Last.fm
erno @ Bash.org wrote:I've lost a machine.. literally _lost_. it responds to ping, it works completely, I just can't figure out where in my apartment it is.
User avatar
JunglistPerfection
Registered User
Posts: 611
Joined: Mon Apr 09, 2007 11:58 pm
Location: Chicago, IL

Re: [BETA] Auto Image Resize 0.0.2 (Non-JavaScript)

Post by JunglistPerfection »

The page load is not that bad, but it would be nice if it could be a little faster. But I don't mind waiting for the updates for this mod.
sopas
Registered User
Posts: 275
Joined: Mon Feb 09, 2004 3:46 am

Re: [BETA] Auto Image Resize 0.0.2 (Non-JavaScript)

Post by sopas »

I only find one "problem" with this MOD: HOw can I do so when I click on to see the enlarged image I can scroll up and down in the pop up window? There are no scroll bars in the pop up window?

Is is possible to just open to enlarged picture on a new browser instead that on a pop up window?
User avatar
JunglistPerfection
Registered User
Posts: 611
Joined: Mon Apr 09, 2007 11:58 pm
Location: Chicago, IL

Re: [BETA] Auto Image Resize 0.0.2 (Non-JavaScript)

Post by JunglistPerfection »

sopas wrote:I only find one "problem" with this MOD: HOw can I do so when I click on to see the enlarged image I can scroll up and down in the pop up window? There are no scroll bars in the pop up window?

Is is possible to just open to enlarged picture on a new browser instead that on a pop up window?
I get the same problem also, but I prefer a pop-up window.
User avatar
MaidenFan
Registered User
Posts: 43
Joined: Mon Dec 12, 2005 3:33 pm
Location: Aberystwyth, Wales, UK

Re: [BETA] Auto Image Resize 0.0.2 (Non-JavaScript)

Post by MaidenFan »

sopas wrote:How can I do so when I click on to see the enlarged image I can scroll up and down in the pop up window? There are no scroll bars in the pop up window?
I've used JavaScript to open the new window because the "target" attribute has been removed from the XHTML Strict language (the attribute is still present in the Transitional version), and I've just updated the JavaScript to allow scrollbars within the window, so copy this line in place of the previous one that output the JavaScript:

Code: Select all

if ($resize){ $return .= "<a href=\"javascript::\" onclick=\"window.open('$url','_blank','Image', 'width=$window_width, height=$window_height, scrollbars=yes, location=no, directories=no, menubar=no, status=no, toolbar=no, top=10, left=10')\">"; }
sopas wrote:Is is possible to just open to enlarged picture on a new browser instead that on a pop up window?
I assume you mean a new browser window. I haven't come across a way of opening something in a new browser window that doesn't require JavaScript for the reasons above, so if you really want to open the link in a new window, edit the same line referenced above to:

Code: Select all

if ($resize){ $return .= "<a href=\"$url\" target=\"_blank\">"; }
But note: this will cause your forum's XHTML to become invalid if you use the Strict DTD (which I think phpBB3 does by default).
Personal Site & Blog | Last.fm
erno @ Bash.org wrote:I've lost a machine.. literally _lost_. it responds to ping, it works completely, I just can't figure out where in my apartment it is.
sopas
Registered User
Posts: 275
Joined: Mon Feb 09, 2004 3:46 am

Re: [BETA] Auto Image Resize 0.0.3 (Non-JavaScript)

Post by sopas »

Man you are fast replying!!!

Thanks a lot. I will check the new code and let you know if I run into problems.

thanks again.
sopas
Registered User
Posts: 275
Joined: Mon Feb 09, 2004 3:46 am

Re: [BETA] Auto Image Resize 0.0.3 (Non-JavaScript)

Post by sopas »

I have made some test with this MOD and I all is fine.

The only concern I have is the time it takes to load the threads that contain photos. If it is only 1 or 2 photos is OK, but if you try to open a thread with let's say 10 photos it can take forever. The problem is not only with loading the photos but opening the threads.

Anyway, I like it.
User avatar
MaidenFan
Registered User
Posts: 43
Joined: Mon Dec 12, 2005 3:33 pm
Location: Aberystwyth, Wales, UK

Re: [BETA] Auto Image Resize 0.0.3 (Non-JavaScript)

Post by MaidenFan »

sopas wrote:The only concern I have is the time it takes to load the threads that contain photos. If it is only 1 or 2 photos is OK, but if you try to open a thread with let's say 10 photos it can take forever. The problem is not only with loading the photos but opening the threads.
This has been raised before, it's the consequence of testing the image on the server-side with PHP rather than on the client (browser) side with JavaScript, as the getimagesize() PHP function that's used to get the size of the image actually downloads the entire image from the destination and then analyses it. Give the script a 2.5MB high-res JPEG for example and it will download all 2.5MB of it and then discard it once it's got the data.

Possible ways of getting around this are on the first page of this thread, although I haven't yet found one that's both easy to implement and doesn't have it's own adverse downsides.
Personal Site & Blog | Last.fm
erno @ Bash.org wrote:I've lost a machine.. literally _lost_. it responds to ping, it works completely, I just can't figure out where in my apartment it is.
sopas
Registered User
Posts: 275
Joined: Mon Feb 09, 2004 3:46 am

Re: [BETA] Auto Image Resize 0.0.3 (Non-JavaScript)

Post by sopas »

I see.
Dont worry, I can wait until the next update.

When I was running phpBB2 I used the following MOD to deal with large images:

http://www.phpbb.com/community/viewtopi ... 4&t=243046

I don't think it works in phpBB3 but I have not tried. It was excellent and worked fine for me during 4 years. You may want to check it out if it gives you ideas.

A week ago I upgraded to phpBB3 and that's why I am looking for a new MOD to deal with image resize.
User avatar
*Capmaster*
Registered User
Posts: 159
Joined: Tue Mar 20, 2007 5:00 pm
Location: Albuquerque, NM

Re: [BETA] Auto Image Resize 0.0.3 (Non-JavaScript)

Post by *Capmaster* »

Very nice mod, MaidenFan 8-) Thank you for writing this.

I had a slow Java resizer when the forum was running phpBB2. I had to remove it because of CPU load.

This one seems to really work fast on my dedicated server. No issues.

One thing - you might include instructions for tweaking the hard-coded image limit, unless you're planning to incorporate that into an ACP setting.

I'm assuming I just change this:

Code: Select all

if ($dimensions[0] > 500) {
               $resize = true;
               $ratio = 500/$dimensions[0];
               $imageHeight = round($dimensions[1]*$ratio);
               $imageWidth = "500";
to this:

Code: Select all

if ($dimensions[0] > 1100) {
               $resize = true;
               $ratio = 1100/$dimensions[0];
               $imageHeight = round($dimensions[1]*$ratio);
               $imageWidth = "1100";
to get the desired limit of 1100 pixels width max for my forum. Is this correct?
User avatar
MaidenFan
Registered User
Posts: 43
Joined: Mon Dec 12, 2005 3:33 pm
Location: Aberystwyth, Wales, UK

Re: [BETA] Auto Image Resize 0.0.3 (Non-JavaScript)

Post by MaidenFan »

Thanks for the comments - if I'm honest I'd forgotten I'd even created this thread :lol:

Yes, you can change 500 to any size you want - the downside of doing everything server-side is that you're effectively downloading every image twice, once to check it's size and once when the page renders, unless you have some kind of cache of either the images, their metadata or both. As yet I haven't found an easily-implementable caching solution :(
Personal Site & Blog | Last.fm
erno @ Bash.org wrote:I've lost a machine.. literally _lost_. it responds to ping, it works completely, I just can't figure out where in my apartment it is.
User avatar
*Capmaster*
Registered User
Posts: 159
Joined: Tue Mar 20, 2007 5:00 pm
Location: Albuquerque, NM

Re: [BETA] Auto Image Resize 0.0.3 (Non-JavaScript)

Post by *Capmaster* »

:D

I ended up settling on 1000 max. width because at 1100, it broke two of the subsilver2-based style layouts on a 1280x1024 display. It works like a charm now 8-)

Return to “[3.0.x] Abandoned MODs”