[Beta] Easy Resize Posted Images - phpbb3.0.x

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment!
Scam Warning
Locked
culosucio
Registered User
Posts: 4
Joined: Thu Mar 20, 2008 9:30 pm

Re: [Beta] Easy Resize Posted Images - phpbb3.0.0

Post by culosucio » Fri Mar 21, 2008 1:57 pm

Well, now that you mention it, I see what I did... So I might be killing another feature :? ...

What solution would you recommend for this case? Is there a "healthier" way?

User avatar
mej284
Registered User
Posts: 1126
Joined: Fri Nov 02, 2007 11:38 am

Re: [Beta] Easy Resize Posted Images - phpbb3.0.0

Post by mej284 » Sat Mar 22, 2008 1:14 am

culosucio wrote:Well, now that you mention it, I see what I did... So I might be killing another feature :? ...

What solution would you recommend for this case? Is there a "healthier" way?
Try this http://www.mediafire.com/?lnbxa0tjia7.

Also if you post a copy of your source code when you are in viewtopic I should be able to let you know of any other changes they may need to be done.
I do not respond to unsolicited PM's

Skin-lab styles
SubMerged Style

kricks99
Registered User
Posts: 15
Joined: Fri Jan 04, 2008 6:39 pm

Re: [Beta] Easy Resize Posted Images - phpbb3.0.0

Post by kricks99 » Sat Mar 22, 2008 2:22 am

mej284 wrote:
culosucio wrote:Well, now that you mention it, I see what I did... So I might be killing another feature :? ...

What solution would you recommend for this case? Is there a "healthier" way?
Try this http://www.mediafire.com/?lnbxa0tjia7.

Also if you post a copy of your source code when you are in viewtopic I should be able to let you know of any other changes they may need to be done.
So is this a good work around for a fix for this mod?

User avatar
mej284
Registered User
Posts: 1126
Joined: Fri Nov 02, 2007 11:38 am

Re: [Beta] Easy Resize Posted Images - phpbb3.0.0

Post by mej284 » Sat Mar 22, 2008 8:10 am

kricks99 wrote:
mej284 wrote:
culosucio wrote:Well, now that you mention it, I see what I did... So I might be killing another feature :? ...

What solution would you recommend for this case? Is there a "healthier" way?
Try this http://www.mediafire.com/?lnbxa0tjia7.

Also if you post a copy of your source code when you are in viewtopic I should be able to let you know of any other changes they may need to be done.
So is this a good work around for a fix for this mod?
I think so.
I do not respond to unsolicited PM's

Skin-lab styles
SubMerged Style

kricks99
Registered User
Posts: 15
Joined: Fri Jan 04, 2008 6:39 pm

Re: [Beta] Easy Resize Posted Images - phpbb3.0.0

Post by kricks99 » Sat Mar 22, 2008 2:29 pm

SWEET! thanks for posting that!

stephb7
Registered User
Posts: 2
Joined: Wed Aug 10, 2005 4:18 am

Re: [Beta] Easy Resize Posted Images - phpbb3.0.0

Post by stephb7 » Sun Mar 23, 2008 1:20 pm

I've slightly modified the original code such that the image's size checks both the width and the height and if either exceeds the specified values then the image is resized and displayed in a popup window. Unfortunately that popup window does not correctly center within the screen. Finally the modifications have been centralized into a single file which is then added/linked to the various styles. This makes it easier to work on the code and have it work in any style rather than having to update each and every style whenever the code is modified.


Create the following file:
.\styles\ImageResizeAndPopup.html

Code: Select all

<script language='javascript'>
    // ./styles/ImageResizeAndPopup.html
    // Stéphane Bessette 2008/03/23

    // Adapted from: Open a window with the right dimension for an image
    // http://www.rgagnon.com/jsdetails/js-0094.html
    function popupFullImage(mytitle, myimage)
    {
        // Create a new image to obtain its dimensions
        image = new Image();
        image.src = myimage;
        image.width  +=  10; // Account for frame borders
        image.height += 100; // Account for titlebar, address, status

        // Calculate the upper top-left position based on the screen and image width
        if(image.width < screen.width)
            leftPos = Math.round((screen.width - image.width) / 2);
        else
            leftPos = 0;
        if(image.height < screen.height)
            topPos  = Math.round((screen.height - image.height) / 2);
        else
            topPos = 0;

        // Prepare the HTML code for the new window
        html = "<HTML><HEAD><TITLE>" + mytitle
             + "</TITLE>"
             + "</HEAD><BODY LEFTMARGIN=0 ";

        if(window.screen.availWidth < image.width || window.screen.availHeight < image.height)
        {
            html = html + "scroll='yes' "; // Image size exceeds desktop dimension so scrollbars are needed
            resize = 1; // In this situation the window is also resizable
        }
        else
        {
            resize = 0; // Do not permit to resize
        }

        html = html
             + "MARGINWIDTH=0 TOPMARGIN=0 MARGINHEIGHT=0><CENTER>" 
             + "<IMG SRC='" + myimage + "' BORDER=0 NAME=image " 
             + 'onload="window.resizeTo(document.image.width, document.image.height);" '
             + "onClick='window.close()' " // Click the image to close the window
             + "style=\"cursor:hand\" " // Show the appropriate cursor
             + ">"
             + "</CENTER>" 
             + "</BODY></HTML>";

        // Open the popup window at the specified positions
        popup= window.open('',
                           '',
                           'top='+topPos+',left='+leftPos+',toolbar=0,location=0,directories=0,menuBar=0,resizable='+resize+',statusBar=0');
        popup.document.open();
        popup.document.write(html);
        popup.document.focus();
        popup.document.close();
    };
            
            
    // Adapted from:  Easy Resize Posted Images
    // http://phpbbegypt.com/phpBB3/viewtopic.php?f=9&t=79
    window.onload = ResizeImageIfTooLarge; 
    function ResizeImageIfTooLarge() 
    {
        // Define the allowed width and height
        maxWidth  = 600;
        maxHeight = 600;
        if (document.getElementsByTagName) 
        { 
            for (i=0; i<document.getElementsByTagName('img').length; i++) 
            { 
                resize = 0;
                im     = document.getElementsByTagName('img')[i]; 
                if (im.width > maxWidth) 
                {
                    // Image width exceeds allowed width
                    im.style.width = maxWidth + 'px';
                    resize         = 1;
                }
                if (im.height > maxHeight) 
                { 
                    // Image height exceeds allowed height
                    im.style.height = maxHeight + 'px'; 
                    resize          = 1;
                }
                if(resize == 1)
                {
                    // The image needs to be resized
                    eval("pop" + String(i) + " = new Function(\"popupFullImage('image', '" + im.src + "');\")"); 
                    eval("im.onclick = pop" + String(i) + ";");
                    if (document.all) im.style.cursor = 'hand'; 
                    if (!document.all) im.style.cursor = 'pointer'; 
                    im.title = 'Click To Enlarge The Image'; 
                } 
            } 
        } 
    } 
</script> 

Modify scheme files as per these (modified) instructions:

Code: Select all

############################################################## 
## 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.1.1
## PHPBB versions: phpbb3 -( RC1 -> 3.0.0 ) 
## Installation Level: (Easy) 
## Installation Time: 3 Minute 
## Files To Edit:  styles/prosilver/template/viewtopic_body.html  
                         styles/subsilver2/template/viewtopic_body.html   
## Included Files:
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2 
##############################################################
## For security purposes, please check: http://www.phpbb.com/mods/
## for the latest version of this MOD. Although MODs are checked
## before being allowed in the MODs Database there is no guarantee
## that there are no security problems within the MOD. No support
## will be given for MODs not found within the MODs Database which
## can be found at http://www.phpbb.com/mods/
##############################################################
## Author Notes: 
## Tested with phpbb3.0.0
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
############################################################## 
# 
#-----[ OPEN ]------------------------------------------ 
# 
styles/prosilver/template/viewtopic_body.html 
# 
#-----[ FIND ]------------------------------------------ 
# 
          <!-- ELSE -->
         <strong>{L_FORUM_RULES}</strong><br />
         {FORUM_RULES}
      <!-- ENDIF -->

      <span class="corners-bottom"><span></span></span></div>
   </div>
<!-- ENDIF -->
# 
#-----[ AFTER , ADD ]------------------------------------------ 

<!-- INCLUDE ../../ImageResizeAndPopup.html -->
# 
#-----[ OPEN ]------------------------------------------ 
# 
styles/subsilver2/template/viewtopic_body.html 
# 
#-----[ FIND ]------------------------------------------ 
# 
<!-- INCLUDE overall_header.html -->
#
#-----[ AFTER , ADD ]------------------------------------------ 

<!-- INCLUDE ../../ImageResizeAndPopup.html -->
# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM  

ToXiQ
Registered User
Posts: 69
Joined: Mon Jun 05, 2006 4:54 pm

Re: [Beta] Easy Resize Posted Images - phpbb3.0.0

Post by ToXiQ » Sun Mar 23, 2008 3:38 pm

this is a great mod and maybe it is possible to ad the Lightbox version in it. Then it would me a perfect mod ;)

moustafamin
Registered User
Posts: 230
Joined: Thu Aug 30, 2007 8:10 am

Re: [Beta] Easy Resize Posted Images

Post by moustafamin » Sun Mar 23, 2008 5:15 pm

kber wrote:
moustafamin wrote:hi kber

really nice mod

but it didn't work on my system :cry:

i am using hoteditor does that effect??

or i may have another problem???
which hoteditor are you used?
HotEditor V.4.2

It would be great if your mod is compatible with it

TheExoticFishDOTcom
I've Been Banned!
Posts: 88
Joined: Sun Mar 23, 2008 8:11 pm
Contact:

Re: [Beta] Easy Resize Posted Images - phpbb3.0.0

Post by TheExoticFishDOTcom » Sun Mar 23, 2008 8:16 pm

I tried adding this to my viewtopic_body.html file and I couldn't get it to work even after Purging the cache. I'm using the Rainbow Pearl theme/style(http://www.phpbb3styles.net/db/style/Rainbow+Pearl). Would anyone mind helping me ?

User avatar
kber
Registered User
Posts: 986
Joined: Sun May 07, 2006 9:22 am
Location: Egypt
Contact:

Re: [Beta] Easy Resize Posted Images - phpbb3.0.0

Post by kber » Sun Mar 23, 2008 8:41 pm

TheExoticFishDOTcom wrote:I tried adding this to my viewtopic_body.html file and I couldn't get it to work even after Purging the cache. I'm using the Rainbow Pearl theme/style(http://www.phpbb3styles.net/db/style/Rainbow+Pearl). Would anyone mind helping me ?
are you install any other mod in the viewtopic_body.html file ?

ToXiQ - moustafamin . i already work on this
Hello All

ToXiQ
Registered User
Posts: 69
Joined: Mon Jun 05, 2006 4:54 pm

Re: [Beta] Easy Resize Posted Images - phpbb3.0.0

Post by ToXiQ » Sun Mar 23, 2008 8:47 pm

kber wrote:
TheExoticFishDOTcom wrote:
ToXiQ - moustafamin . i already work on this
Whow can't wait to see first release :D

TheExoticFishDOTcom
I've Been Banned!
Posts: 88
Joined: Sun Mar 23, 2008 8:11 pm
Contact:

Re: [Beta] Easy Resize Posted Images - phpbb3.0.0

Post by TheExoticFishDOTcom » Sun Mar 23, 2008 8:58 pm

kber wrote:
TheExoticFishDOTcom wrote:I tried adding this to my viewtopic_body.html file and I couldn't get it to work even after Purging the cache. I'm using the Rainbow Pearl theme/style(http://www.phpbb3styles.net/db/style/Rainbow+Pearl). Would anyone mind helping me ?
are you install any other mod in the viewtopic_body.html file ?

ToXiQ - moustafamin . i already work on this
No, I only tried to add this Mod, nothing else.

ToXiQ
Registered User
Posts: 69
Joined: Mon Jun 05, 2006 4:54 pm

Re: [Beta] Easy Resize Posted Images - phpbb3.0.0

Post by ToXiQ » Sun Mar 23, 2008 10:03 pm

Hello kber,

Instead of lighbox there is a smaller version with same functionality available and is called slimbox. Also a link .

http://www.digitalia.be/software/slimbox

regards Walter

User avatar
kber
Registered User
Posts: 986
Joined: Sun May 07, 2006 9:22 am
Location: Egypt
Contact:

Re: [Beta] Easy Resize Posted Images - phpbb3.0.0

Post by kber » Mon Mar 24, 2008 3:36 pm

ToXiQ wrote:Hello kber,

Instead of lighbox there is a smaller version with same functionality available and is called slimbox. Also a link .

http://www.digitalia.be/software/slimbox

regards Walter
Will be taken in the preparation thanks :)
Hello All

freedomgli
Registered User
Posts: 3
Joined: Mon Mar 24, 2008 3:49 pm

Re: [Beta] Easy Resize Posted Images - phpbb3.0.0

Post by freedomgli » Mon Mar 24, 2008 4:00 pm

stephb7 wrote:I've slightly modified the original code such that the image's size checks both the width and the height and if either exceeds the specified values then the image is resized and displayed in a popup window.
Thanks Stéphane. I like the way you reference the code so I don't have to do much modification with each theme. I'm using prosilver theme and it works okay. Unfortunately, there are a few bugs:
  • Scroll bars on pop up window do not activate when necessary (e.g. when image resolution greater than screen resolution) with Firefox but they do appear to work with IE7
  • It doesn't work for me with IE7. When I removed the
    <!-- INCLUDE ../../ImageResizeAndPopup.html --> my forum worked again but obviously the image resize didn't. Perhaps it has something to do with w3c xhtml 1.0 strict encoding.
I'm not smart when it comes to programming but I'll see what I can do to debug these issues.

Locked

Return to “[3.0.x] MODs in Development”