[2.0.18] Simple Mod Resize Images

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in here. No new MODs will be accepted into the MOD Database for phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.

Rating:

Excellent!
11
55%
Very Good
4
20%
Good
3
15%
Fair
0
No votes
Poor
2
10%
 
Total votes: 20

trek7k
Registered User
Posts: 4
Joined: Tue Mar 28, 2006 2:46 pm
Location: Durham, NC
Contact:

Alternate mod

Post by trek7k » Tue Mar 28, 2006 2:56 pm

I tried a similar javascript mod to the one mentioned above but I wasn't satisfied. The images resize correctly but my page layout was still broken since the images are resized AFTER the html is loaded leaving me with white space where the large images USED to be.

I dug deep into the PHPBB code and added a little hack of my own, though I admit it still isn't perfect. Using php's getimagesize function I modify the image size tags as the BBCode is parsed (I'm only allowing BBCode, no HTML in my forums). Take a look:

Code: Select all

includes/bbcode.php

# Original image replacement code, commented so it does not execute
#	$patterns[] = "#\[img:$uid\]([^?].*?)\[/img:$uid\]#i";
#	$replacements[] = $bbcode_tpl['img'];


	$pattern1 = "#\[img:$uid\]([^?].*?)\[/img:$uid\]#i";
	preg_match_all($pattern1, $text, $imageURL);

	foreach ($imageURL[1] as $key => $val){
		if ($val){
			$imageSize = getimagesize($val);
			if ($imageSize[0] > 400){$imageWidth = 400; $imageHeight = $imageSize[1] * (400 / $imageSize[0]);}
				else {$imageWidth = $imageSize[0]; $imageHeight = $imageSize[1];}
			$pattern1 = "#\[img:$uid\]($val)\[/img:$uid\]#i";
			$replacement1 = "<img src=\"$val\" height=\"$imageHeight\" width=\"$imageWidth\" border=\"0\" />";
			$text = preg_replace($pattern1, $replacement1, $text);
		}
	}
This code resizes images such that none are wider than 400 pixels (just replace 400 with your desired width in the code above). The problem I'm finding now is that some of my users store their photos on servers that don't allow URL requests of files (and so the getimagesize function fails for those images). Anyone have any ideas?

Eddy Kiprich
Registered User
Posts: 149
Joined: Sun Dec 18, 2005 1:22 pm
Location: The Netherlands

Post by Eddy Kiprich » Sat May 13, 2006 11:24 pm

Can it be possible to auto-resize images on the blogging system as well?
http://theblogmod.com/community/index.php

Spydey
Registered User
Posts: 4
Joined: Wed Jun 21, 2006 2:34 am

Post by Spydey » Mon Jul 10, 2006 6:54 am

Eddy Kiprich wrote:
MennoniteHobbit wrote:Since the MOD uses JavaScript, you should check to see if your browser supports JavaScript ("supports" also including "is enabled").

Since the code is put into overall_header.tpl, you should note that the resize images feature will apply to all images. The not loading bit seems to be different, however. It may just be your Internet connection.


My laptop supports javascript and it is enabled. Also I think that every user on our forum suffers missing pictures. Only with a refresh (F5) the pictures will return.


Hi guys, I am also seeing the same issue as everyone else. This only occurs in IE btw. I usually have to press F5 twice before the pictures reappear. Any ideas on how to fix it?

surfermorph
Registered User
Posts: 29
Joined: Sat Aug 19, 2006 4:04 am

any update?

Post by surfermorph » Sat Aug 19, 2006 10:31 pm

Hi there

I'm having the same problem using this mod with IE - essentially having to refresh the page a couple times for the images to appear. Is there any fix or suggestions?

Alternatively, is there any possibility of "un-installing" this mod?

Thanks in advance for your help.

jamiejones
Registered User
Posts: 12
Joined: Mon Sep 27, 2004 3:04 am

Post by jamiejones » Tue Oct 31, 2006 12:40 am

try this one:

http://phpbbmods.bishopston.net/topic_33.html

Simple to install, and demo on that page too.

James_jamz
Registered User
Posts: 1
Joined: Thu Nov 23, 2006 4:25 pm

Post by James_jamz » Thu Nov 23, 2006 4:26 pm

I keep getting the error "Stack Overflow at line:"

Any ideas?

rocketsep
Registered User
Posts: 21
Joined: Thu Sep 28, 2006 10:22 pm

Post by rocketsep » Sat Nov 25, 2006 5:41 pm

Femma wrote:
jessan wrote:Didnt work. Nothing happens


Same here, did not work.


it did not work the first time I tried it. There seems to be an issue as to the location of the js file.
copy SMRcode.js to templates/SMRcode.js


It worked after I moved SMRcode to templates/subsilver/SMRcode.js (substitute subsilver for the style you are using)
nycore wrote: Does this resize based on some preset width or is it adjustable by admin? I dont see any admin files edited. No admin adjustability?


You need to edit the 4th line in SMRcode.js
SMR_confMaxDim = 350; // pixels


Change the '350' to the maximum size in pixels you require

Veron
Registered User
Posts: 185
Joined: Fri Feb 24, 2006 6:14 pm
Location: Slovenia

Post by Veron » Fri Dec 01, 2006 10:54 pm

I would like to ask if it is possible to make some changes to this code, so pictures smaller then 430 would not get link.

I mean that "function SMR_setLink(obj)" would not be set to pictures smaller then 430.
Probably will be needed one IF (this.width=<430).. else System.out(0)
. But i can not figure out how to do it proparly to work normally.

I end, picuters bigger then 430 must get liked (function SMR_setLink(obj)) and pictures smaller or 430 must not get link (function SMR_setLink(obj) must not be included)

Code: Select all

//*******************************************************************
//** SMR_RESIZE_MOD: CONFIGURATION **********************************
//*******************************************************************
SMR_confMaxDim = 430; // pixels

//*******************************************************************
//** SMR_RESIZE_MOD: START CODE *************************************
//*******************************************************************

function SMR_resize(obj) {

   thisWidth = obj.width;
   thisHeight = obj.height;
   
   if(thisWidth > thisHeight) thisMaxDim = thisWidth;
   else thisMaxDim = thisHeight;
   
   if(thisMaxDim > SMR_confMaxDim) {
      thisMinDim = Math.round((((thisWidth > thisHeight)?thisHeight:thisWidth) * SMR_confMaxDim) / thisMaxDim); 
      
      if(thisWidth > thisHeight) {
         thisWidth = SMR_confMaxDim;
         thisHeight = thisMinDim;
      } else {
         thisHeight = SMR_confMaxDim;
         thisWidth = thisMinDim;
      }
     SMR_setLink(obj)
   } // if(thisMaxDim > SMR_confMaxDim)

   obj.height = thisHeight;
   obj.width = thisWidth;
}

function SMR_setLink(obj) {
   thisInnerHtml = obj.innerHTML;
   tmpArray = thisInnerHtml.split(' src=\"');
   tmpArray = tmpArray[1].split('"');
   obj.href = tmpArray[0];
}
//*******************************************************************
//** SMR_RESIZE_MOD: END ********************************************
//*******************************************************************

User avatar
freddie
Registered User
Posts: 404
Joined: Sun Mar 31, 2002 1:40 pm
Location: Estes Park, USA
Contact:

Post by freddie » Thu Jan 25, 2007 7:07 pm

this mod isn't working on all images on my board ...

diabolic.bg
Registered User
Posts: 447
Joined: Mon Dec 11, 2006 3:41 pm
Location: Bulgaria, Sofia
Contact:

Post by diabolic.bg » Wed Feb 07, 2007 11:53 am

Not bad but again it have a problem with IE - some pictures hide. 8O

loyal_and_true
Registered User
Posts: 251
Joined: Thu Mar 23, 2006 6:46 pm

Post by loyal_and_true » Tue Feb 20, 2007 9:15 pm

Works great with big images thanks...

only thing is on my forum when Thumbnail Images are posted they display perfectly fine but when you click the thumb its meant to go the large image right well it goes to the same small thumbnail as displayed in the thread with the size below it...

Its just started doing it never done it before

Any Ideas ??

Thanks

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51889
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Post by Brf » Tue Feb 20, 2007 9:20 pm

Is that a link to an imageshack thumb?

loyal_and_true
Registered User
Posts: 251
Joined: Thu Mar 23, 2006 6:46 pm

Post by loyal_and_true » Tue Feb 20, 2007 9:53 pm

Brf wrote: Is that a link to an imageshack thumb?


Yes

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51889
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Post by Brf » Tue Feb 20, 2007 9:54 pm

Ah. Then you made a thumb of the thumb. You should be inserting the link to the actual picture, not the thumb.

loyal_and_true
Registered User
Posts: 251
Joined: Thu Mar 23, 2006 6:46 pm

Post by loyal_and_true » Tue Feb 20, 2007 10:44 pm

I am posting the correct line!

Thumbnail for forums (1)

Code: Select all

[URL=http://img165.imageshack.us/my.php?image=tartanarmyflagja7.jpg][IMG]https://camo.phpbb.com/e48130cf95defcfb3e32a5f9f74a68d8463c6c5c/687474703a2f2f696d673136352e696d616765736861636b2e75732f696d673136352f363134312f74617274616e61726d79666c61676a61372e74682e6a7067[/IMG][/URL]
Image

It works on here but on my forum It goes to a page of the thumb itself

Post Reply

Return to “[2.0.x] MOD Database Releases”