1
m0nty
AUTO Thumbnail on img tag (img manager) in posts
  • 2005/12/20 9:39

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


If users link to images that are large in size, this can result in a stretched page.. likewise if you don't want large images to be displayed and only want a thumbnail image to be viewed instead (a link underneath each image will show the full size image) then this hack is what you need..

open class/module.textsanitizer.php

FIND:

if ($allowimage != 1) {
            
$replacements[] = '<a href="\3" target="_blank">\3</a>';
            
$replacements[] = '<a href="\1" target="_blank">\1</a>';
            
$replacements[] = '<a href="'.XOOPS_URL.'/image.php?id=\4" target="_blank">\4</a>';
            
$replacements[] = '<a href="'.XOOPS_URL.'/image.php?id=\2" target="_blank">\3</a>';
        } else {
            
$replacements[] = '<img src="\3" align="\2" alt="" />';
            
$replacements[] = '<img src="\1" alt="" />';
            
$replacements[] = '<img src="'.XOOPS_URL.'/image.php?id=\4" align="\2" alt="\4" />';
            
$replacements[] = '<img src="'.XOOPS_URL.'/image.php?id=\2" alt="\3" />';
        }


replace with:

if ($allowimage != 1) {
            
$replacements[] = '<div class="thumb"><a href="\3" target="_blank">\3</a></div>';
            
$replacements[] = '<div class="thumb"><a href="\1" target="_blank">\1</a></div>';
            
$replacements[] = '<div class="thumb"><a href="'.XOOPS_URL.'/image.php?id=\4" target="_blank">\4</a></div>';
            
$replacements[] = '<div class="thumb"><a href="'.XOOPS_URL.'/image.php?id=\2" target="_blank">\3</a></div>';
        } else {
            
$replacements[] = '<div class="thumb"><img src="\3" align="\2" alt="" /></div>';
            
$replacements[] = '<div class="thumb"><img src="\1" alt="" /></div>';
            
$replacements[] = '<div class="thumb"><img src="'.XOOPS_URL.'/image.php?id=\4" align="\2" alt="\4" /></div>';
            
$replacements[] = '<div class="thumb"><img src="'.XOOPS_URL.'/image.php?id=\2" alt="\3" /></div>';
        }



open include/xoops.js

add this to the bottom of the file:
(to change the width of thumbnail, then change the width value (250) to what size you want in both places in the below function)

function ImagesResize() {
  var 
obj document.getElementsByTagName("div");
  for(var 
0;i<obj.length;i++) {
    if (
obj[i].className == "thumb") {
      var 
img obj[i].getElementsByTagName("img");
      if (
img[0].width 250) { obj[i].innerHTML '<div align=center><img src="' img[0].src '" width="250">' '<br><a href="' img[0].src '" target="_blank">Show Image In Full Size</a></div>'; }
    }
  }
}


open themes/your theme/theme.html

find

<body>


replace with:

<body onLoad="ImagesResize()">


open themes/your theme/style.css

add this class:

.thumb {
    
displayblock;
    
clearall;
}


you're finished..

now whenever someone uses the [ img] tag on your site a thumbnail will be used instead of the full size image.

note: existing images will not be altered, to change existing images then you would need to edit the post/article etc and submit it again.

2
Watdehek
Re: AUTO Thumbnail on img tag (img manager) in posts
  • 2005/12/20 9:43

  • Watdehek

  • Friend of XOOPS

  • Posts: 130

  • Since: 2005/2/21


This is a very usefull hack.

I hate those large images posted in the [img]-tag!

3
defwind77
Re: AUTO Thumbnail on img tag (img manager) in posts
  • 2005/12/20 10:05

  • defwind77

  • Not too shy to talk

  • Posts: 180

  • Since: 2005/11/11


hmm this works great when inserting an image - however is there a reason it fails when I'm inserting more than one image into an article? I'm using smartsection and I've inserted three images into an article and only the first one appears?

Any ideas?

4
m0nty
Re: AUTO Thumbnail on img tag (img manager) in posts
  • 2005/12/20 10:17

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


not sure..

i've tested with cbb and it works fine no matter how many images are posted..

5
m0nty
Re: AUTO Thumbnail on img tag (img manager) in posts
  • 2005/12/20 10:28

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


have just tested with smartsection on my test site, and it works fine.

http://72.29.75.243/~wwcncom/wwcn/modules/smartsection/item.php?itemid=1

6
defwind77
Re: AUTO Thumbnail on img tag (img manager) in posts
  • 2005/12/20 11:39

  • defwind77

  • Not too shy to talk

  • Posts: 180

  • Since: 2005/11/11


how bizarre?!

This is the text I've entered into smartsection:


img align=left]http://www.studioeb.com/VFX_05_MP_Castle.jpg[/img]

Stunning matte paintings and digital work by Studio EB They have a tremendous gallery of images that are well worth viewing.

img align=left]http://www.studioeb.com/MP2_Aztec_model.htm[/img]

You will finds dozens of images that they have sketched out as visualisation for scenes as well as textures and digital art that have produced.

img align=right]http://www.studioeb.com/rome2.htm[/img]


And it shows:


Here

Can you spot any silly mistakes I've made?

I'm using Smartsection 1.05 & XOOPS 2.2.3

PS I've left the first [ pff each img tag here cos it kept wanting to display the pictures! Interestingly though it too only displayed the first picture?!

7
m0nty
Re: AUTO Thumbnail on img tag (img manager) in posts
  • 2005/12/20 11:42

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


hmmm the properties of the images that aren't showing are saying it's a htm file not an image

http://www.studioeb.com/MP2_Aztec_model.htm

8
defwind77
Re: AUTO Thumbnail on img tag (img manager) in posts
  • 2005/12/20 13:01

  • defwind77

  • Not too shy to talk

  • Posts: 180

  • Since: 2005/11/11


hmm sometimes I feel my table simply isn't hard enough to bang my head on! I should have seen that!

Thanks very much - works a treat now!

9
ClubNUKE
Re: AUTO Thumbnail on img tag (img manager) in posts
  • 2005/12/20 14:04

  • ClubNUKE

  • Just popping in

  • Posts: 83

  • Since: 2004/9/1 2


Quote:

m0nty wrote:
have just tested with smartsection on my test site, and it works fine.

http://72.29.75.243/~wwcncom/wwcn/modules/smartsection/item.php?itemid=1


Nice hack, thanks!

Note: Monty, do you have wfdownload v3.0???
Resized Image

10
davidl2
Re: AUTO Thumbnail on img tag (img manager) in posts
  • 2005/12/20 15:23

  • davidl2

  • XOOPS is my life!

  • Posts: 4843

  • Since: 2003/5/26


This is still at the beta stage, but should be available soon.

Login

Who's Online

113 user(s) are online (87 user(s) are browsing Support Forums)


Members: 0


Guests: 113


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits