| Author |
Message |
mrix Client

Joined: Dec 04, 2004 Posts: 757
|
Posted:
Wed Oct 14, 2009 11:08 am |
|
Hi all, I installed this mod to help squeeze image smaller when members post huge images which worked great
Unfortunately the mod shrunk my logo example below
Is there any code I could add that will keep it fixed width and not be changed by the mod???
Thanks for any help |
|
|
|
 |
eldorado Involved


Joined: Sep 10, 2008 Posts: 366 Location: France
|
Posted:
Wed Oct 14, 2009 11:40 am |
|
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 |
|
|
|
 |
mrix Client

Joined: Dec 04, 2004 Posts: 757
|
Posted:
Wed Oct 14, 2009 12:17 pm |
|
Hi there, a lot of that code doesn't appear to be relevant and outdated? the mod was posted 2006
thanks anyway
mrix |
|
|
|
 |
eldorado Involved


Joined: Sep 10, 2008 Posts: 366 Location: France
|
Posted:
Wed Oct 14, 2009 1:06 pm |
|
| mrix wrote: | Hi there, a lot of that code doesn't appear to be relevant and outdated? the mod was posted 2006
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  |
Last edited by eldorado on Wed Oct 14, 2009 1:16 pm; edited 1 time in total |
|
|
 |
mrix Client

Joined: Dec 04, 2004 Posts: 757
|
Posted:
Wed Oct 14, 2009 1:16 pm |
|
| Code: | ##############################################################
## MOD Title: Easy Resize Posted Images
## MOD Author: kber < > (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 />
</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> <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"> <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 Involved


Joined: Sep 10, 2008 Posts: 366 Location: France
|
Posted:
Wed Oct 14, 2009 1:22 pm |
|
Ok, the problem is the javascript referring to window.onload. It's supposed to resize every image on the board
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 Client

Joined: Dec 04, 2004 Posts: 757
|
Posted:
Wed Oct 14, 2009 3:09 pm |
|
Hi there, I am a little confused what part of code this is meant to replace?
Cheers
mrix |
|
|
|
 |
mrix Client

Joined: Dec 04, 2004 Posts: 757
|
Posted:
Fri Oct 16, 2009 12:58 am |
|
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 Involved


Joined: Sep 10, 2008 Posts: 366 Location: France
|
Posted:
Fri Oct 16, 2009 8:11 am |
|
| 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 Nice thinking. |
|
|
|
 |
fkelly Moderator

Joined: Aug 30, 2005 Posts: 3136 Location: near Albany NY
|
Posted:
Fri Feb 04, 2011 9:45 am |
|
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. |
|
|
|
 |
slackervaara Worker


Joined: Aug 26, 2007 Posts: 234
|
Posted:
Fri Feb 04, 2011 7:46 pm |
|
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> |
|
|
|
|
 |
|
|
|
|