Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Converting/Creating Themes
Author Message
mrix
Client



Joined: Dec 04, 2004
Posts: 757

PostPosted: Wed Oct 14, 2009 11:08 am Reply with quote

Hi all, I installed this mod to help squeeze image smaller when members post huge images which worked great Very Happy

Unfortunately the mod shrunk my logo Confused Confused Sad Sad example below
http://www.online-gaming-forums.com/ftopict-5335.html

Is there any code I could add that will keep it fixed width and not be changed by the mod???
Thanks for any help
 
View user's profile Send private message Visit poster's website
eldorado
Involved
Involved



Joined: Sep 10, 2008
Posts: 424
Location: France,Translator

PostPosted: Wed Oct 14, 2009 11:40 am Reply with quote

I'm installing the mod.
edit : going to be an issue here...The forum acp doesn't work in php>5.3.
Can you try this mod instead?
in bbcode.php
Code:
# Original image replacement code, commented so it does not execute

#   $patterns[] = "#\[img:$uid\]([^?].*?)\[/img:$uid\]#i";
#   $replacements[] = $bbcode_tpl['img'];


   $ims='400';//Change image max size
   $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] > $ims){$imageWidth = $ims; $imageHeight = $imageSize[1] * ($ims / $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);
      }
   }

found here http://www.phpbb.com/community/viewtopic.php?p=2064036#p2064036

_________________
Only registered users can see links on this board! Get registered or login! (My RN site)- Only registered users can see links on this board! Get registered or login!(cod4 clan) - Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website MSN Messenger
mrix







PostPosted: Wed Oct 14, 2009 12:17 pm Reply with quote

Hi there, a lot of that code doesn't appear to be relevant and outdated? the mod was posted 2006 Confused
thanks anyway
mrix
 
eldorado







PostPosted: Wed Oct 14, 2009 1:06 pm Reply with quote

mrix wrote:
Hi there, a lot of that code doesn't appear to be relevant and outdated? the mod was posted 2006 Confused
thanks anyway
mrix

Ok, can you post the link to the mod please. I'll have less trouble finding what occurs if I know how it works.

Btw , the mod actually is relevant and it works fine on my board Sad


Last edited by eldorado on Wed Oct 14, 2009 1:16 pm; edited 1 time in total 
mrix







PostPosted: Wed Oct 14, 2009 1:16 pm Reply with quote

Code:
############################################################## 

## MOD Title: Easy Resize Posted Images
## MOD Author: kber < webmaster@phpbbegypt.com > (kber) http://www.phpbbegypt.com
## MOD Description:  This MOD resizes images within the posts . Images resized are made
## clickable and openable in a popup in full-size.
## MOD Version: 1.0.0
## PHPBB versions: 2.0.x
## Ported MOD 1/25/2009 by Steve DeMarcus http://stevedemarcus.com
##############################################################
## Note this is a more clear MOD than the original
## and was written for the PHP Nuke Forums as the
## MOD as it was showed a non existant line of text
## probably from a real old version of phpBB. So I included
## all text you should see in PHP Nuke.
##############################################################
## Installation Level: (Very Easy)
## Installation Time: 1 Minute or less.
## Files To Edit:
## modules/Forums/templates/SubSilver/viewtopic_body.tpl
## Included Files: n/a
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ OPEN ]------------------------------------------
#
 modules/Forums/templates/SubSilver/viewtopic_body.tpl

 OR (if using a custom theme, and if using more than 1 theme then modify)

 themes/YOURTHEME/forums/viewtopic_body.tpl
#
#-----[ FIND ]------------------------------------------
#
<table width="100%" cellspacing="2" cellpadding="2" border="0">
  <tr>
   <td align="left" valign="bottom" colspan="2"><a class="maintitle" href="{U_VIEW_TOPIC}">{TOPIC_TITLE}</a><br />
     <span class="gensmall"><b>{PAGINATION}</b><br />
     &nbsp; </span></td>
  </tr>
</table>
#
#-----[ AFTER, ADD ]------------------------------------------
# note : you may change( 600px) to whatever you want
<script>
window.onload = resizeimg;
function resizeimg()
{
   if (document.getElementsByTagName)
   {
      for (i=0; i<document.getElementsByTagName('img').length; i++)
      {
         im = document.getElementsByTagName('img')[i];
         if (im.width > 600)
         {
            im.style.width = '600px';
            eval("pop" + String(i) + " = new Function(\"pop = window.open('" + im.src + " ','fullscale','width=400,height=400,scrollbars=1,resizable=1'); pop.focus();\")");
            eval("im.onclick = pop" + String(i) + ";");
            if (document.all) im.style.cursor = 'hand';
            if (!document.all) im.style.cursor = 'pointer';
            im.title = 'Click Here To See Image Full Size ';
         }
      }
   }
}

</script>
# [ADD BEFORE]
 
<table width="100%" cellspacing="2" cellpadding="2" border="0">
  <tr>
   <td align="left" valign="bottom" nowrap="nowrap"><span class="nav"><a href="{U_POST_NEW_TOPIC}"><img src="{POST_IMG}" border="0" alt="{L_POST_NEW_TOPIC}" align="middle" /></a>&nbsp;&nbsp;&nbsp;<a href="{U_POST_REPLY_TOPIC}"><img src="{REPLY_IMG}" border="0" alt="{L_POST_REPLY_TOPIC}" align="middle" /></a></span></td>
   <td align="left" valign="middle" width="100%"><span class="nav">&nbsp;&nbsp;&nbsp;<a href="{U_INDEX}" class="nav">{L_INDEX}</a>
     -> <a href="{U_VIEW_FORUM}" class="nav">{FORUM_NAME}</a></span></td>
  </tr>
</table>

#
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM 
 
eldorado







PostPosted: Wed Oct 14, 2009 1:22 pm Reply with quote

Ok, the problem is the javascript referring to window.onload. It's supposed to resize every image on the board Sad
edit: would you care to try that one ?
Code:
maxWidth = 600;      // maximum width of images in pixels


var phpBB = true;
}

if (phpBB) {
   var aSpan = document.getElementsByTagName('span');
   for (i=0; i<aSpan.length; i++) {
      if (aSpan[i].className == 'postbody') {
         var aImg = aSpan[i].getElementsByTagName('img');
         for (j=0; j<aImg.length; j++) {
            if (document.defaultView.getComputedStyle(aImg[j], null).getPropertyValue('position') == 'static' && parseInt(document.defaultView.getComputedStyle(aImg[j], null).getPropertyValue('width').replace('px','')) > maxWidth) {
               aImg[j].style.maxWidth = maxWidth + 'px';
               aImg[j].title = 'Click for the original size';
               aImg[j].addEventListener('click', function(event) {
                     if (event.currentTarget.style.maxWidth == 'none') {
                        event.currentTarget.style.maxWidth = maxWidth + 'px';
                        event.currentTarget.title = 'Click for the original size';
                     } else {
                        event.currentTarget.style.maxWidth = 'none';
                        event.currentTarget.title = 'Click for the reduced size';
                     }
                  }, false);
            }
         }
      }
   }
}

edit2: , made a mistake.
 
mrix







PostPosted: Wed Oct 14, 2009 3:09 pm Reply with quote

Hi there, I am a little confused what part of code this is meant to replace?
Cheers
mrix
 
mrix







PostPosted: Fri Oct 16, 2009 12:58 am Reply with quote

Finally found a fix for this mod, basically you change the 0 for a 1 .
before
for (i=0; i<document.getElementsByTagName('img').length; i++)


after
for (i=1; i<document.getElementsByTagName('img').length; i++)


Cheers
mrix
 
eldorado







PostPosted: Fri Oct 16, 2009 8:11 am Reply with quote

mrix wrote:

after
for (i=1; i<document.getElementsByTagName('img').length; i++)


Cheers
mrix

nice one there , you actually skip the first image (the logo)so it doesn't get caught in the loop.You'll have to increment one more if you add another image in your header Smile Nice thinking.
 
fkelly
Former Moderator in Good Standing



Joined: Aug 30, 2005
Posts: 3312
Location: near Albany NY

PostPosted: Fri Feb 04, 2011 9:45 am Reply with quote

Stifen ... I'm not sure your post was relevant to the thread you stuck it in. But in any event, is it possible that your email client is shrinking the attachments in the interest of efficiency? If you have a sent mail folder and you look in it what is the size of the attachment. Or the recipient(s) email clients could be shrinking the attachments.
 
View user's profile Send private message Visit poster's website
slackervaara
Worker
Worker



Joined: Aug 26, 2007
Posts: 236

PostPosted: Fri Feb 04, 2011 7:46 pm Reply with quote

I have used this exception to not resize logo:

Code:


<script type="text/javascript">
   // each script does this:
if (window.addEventListener)
{
   window.addEventListener('load', resizeimg, false);
}
else if (window.attachEvent)
{
   window.attachEvent('onload', resizeimg);
}   
    
     //window.onload = resizeimg;
function resizeimg()
{
   if (document.getElementsByTagName)
   {
      for (i=0; i<document.getElementsByTagName('img').length; i++)
      {
         im = document.getElementsByTagName('img')[i];
        if (im.width > 600 && im.src != "http://www.mysite.com/themes/Nuke13-feb-08/images/head-1.jpg")
              {
            im.style.width = '400px';
            eval("pop" + String(i) + " = new Function(\"pop = window.open('" + im.src + " ','fullscale','width=400,height=400,scrollbars=1,resizable=1'); pop.focus();\")");
            eval("im.onclick = pop" + String(i) + ";");
            if (document.all) im.style.cursor = 'hand';
            if (!document.all) im.style.cursor = 'pointer';
            im.title = 'Click Here To See Image Full Size ';
         }
      }
   }
}

</script>
 
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Converting/Creating Themes

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©