TBDev Forum
Programming board
Main Page Forum Rules Privacy Policy Members Contact Us
Welcome Guest (Login | Register)
TBDev Forum TBDev.net - Mods & hacks Mods Complete & working Forum Mods Resize Large Images
Page 1 2 3 4

Resize Large Images

2008-07-16 21:12:00
Group: Member
Posts: 36
Topics participated: 25
Topics started: 15
First post: 2008-03-02 20:22:00
Last post: 2008-08-19 21:20:00
ncode_imageresizer.rar



please?
 
2008-07-16 21:35:00
Group: Member
Posts: 577
Topics participated: 354
Topics started: 14
First post: 2008-03-01 01:47:00
Last post: 2009-01-03 16:33:00

or alternativley:
ncode_imageresizer.js
NcodeImageResizer.IMAGE_ID_BASE = 'ncode_imageresizer_container_';
NcodeImageResizer.WARNING_ID_BASE = 'ncode_imageresizer_warning_';

function NcodeImageResizer(id, img) {
this.id = id;
this.img = img;
this.originalWidth = 0;
this.originalHeight = 0;
this.warning = null;
this.warningTextNode = null;

img.id = NcodeImageResizer.IMAGE_ID_BASE+id;
}

NcodeImageResizer.getNextId = function() {
id = 1;
while(document.getElementById(NcodeImageResizer.IMAGE_ID_BASE+id) != null) {
id++;
}
return id;
}

NcodeImageResizer.createOn = function(img) {
isRecovery = false; // if this is a recovery from QuickEdit, which only restores the HTML, not the OO structure
if(img.id && img.id.indexOf(NcodeImageResizer.IMAGE_ID_BASE) == 0 && document.getElementById(NcodeImageResizer.WARNING_ID_BASE+img.id.substr(NcodeIma
geResizer.IMAGE_ID_BASE.length)) != null) {
newid = img.id.substr(NcodeImageResizer.IMAGE_ID_BASE.length);
resizer = new NcodeImageResizer(newid, img);
isRecovery = true;
resizer.restoreImage();
} else {
newid = NcodeImageResizer.getNextId();
resizer = new NcodeImageResizer(id, img);
}

if (resizer.originalWidth == 0) resizer.originalWidth = img.width;
if (resizer.originalHeight == 0) resizer.originalHeight = img.height;

if((NcodeImageResizer.MAXWIDTH > 0 && resizer.originalWidth > NcodeImageResizer.MAXWIDTH) || (NcodeImageResizer.MAXHEIGHT > 0 && resizer.originalHeight > NcodeImageResizer.MAXHEIGHT)) {
if(isRecovery) {
resizer.reclaimWarning(warning);
} else {
resizer.createWarning();
}
resizer.scale();
}
}

NcodeImageResizer.prototype.restoreImage = function() {
newimg = document.createElement('IMG');
newimg.src = this.img.src;
this.img.width = newimg.width;
this.img.height = newimg.height;
}

NcodeImageResizer.prototype.reclaimWarning = function() {
warning = document.getElementById(NcodeImageResizer.WARNING_ID_BASE+newid);

this.warning = warning;
this.warningTextNode = warning.firstChild.firstChild.childNodes[1].firstChild;
this.warning.resize = this;

this.scale();
}

NcodeImageResizer.prototype.createWarning = function() {
mtable = document.createElement('TABLE');
mtbody = document.createElement('TBODY');
mtr = document.createElement('TR');
mtd1 = document.createElement('TD');
mtd2 = document.createElement('TD');
mimg = document.createElement('IMG');
mtext = document.createTextNode('');

mimg.src = 'pic/error.gif';
mimg.width = 16;
mimg.height = 16;
mimg.alt = '';
mimg.border = 0;

mtd1.width = 20;
mtd1.className = 'td1';

mtd2.unselectable = 'on';
mtd2.className = 'td2';

mtable.className = 'ncode_imageresizer_warning';
mtable.textNode = mtext;
mtable.resize = this;
mtable.id = NcodeImageResizer.WARNING_ID_BASE+this.id;

mtd1.appendChild(mimg);
mtd2.appendChild(mtext);

mtr.appendChild(mtd1);
mtr.appendChild(mtd2);

mtbody.appendChild(mtr);

mtable.appendChild(mtbody);

this.img.parentNode.insertBefore(mtable, this.img);

this.warning = mtable;
this.warningTextNode = mtext;
}

NcodeImageResizer.prototype.scale = function() {
if(NcodeImageResizer.MAXWIDTH > 0 && this.originalWidth > NcodeImageResizer.MAXWIDTH) {
resized = true;
this.img.width = NcodeImageResizer.MAXWIDTH;
this.img.height = (NcodeImageResizer.MAXWIDTH / this.originalWidth) * this.originalHeight;
}
if(NcodeImageResizer.MAXHEIGHT > 0 && this.originalHeight > NcodeImageResizer.MAXHEIGHT) {
resized = true;
this.img.height = NcodeImageResizer.MAXHEIGHT;
this.img.width = (NcodeImageResizer.MAXHEIGHT / this.originalHeight) * this.originalWidth;
}

this.warning.width = this.img.width;
this.warning.onclick = function() { return this.resize.unScale(); }

if(this.img.width < 450) {
this.warningTextNode.data = NcodeImageResizer.Msg1;
} else if(this.img.fileSize && this.img.fileSize > 0) {
this.warningTextNode.data = NcodeImageResizer.Msg2.replace('%1$s', this.originalWidth).replace('%2$s', this.originalHeight).replace('%3$s', Math.round(this.img.fileSize/1024));
} else {
this.warningTextNode.data = NcodeImageResizer.Msg3.replace('%1$s', this.originalWidth).replace('%2$s', this.originalHeight);
}

return false;
}

NcodeImageResizer.prototype.unScale = function() {
switch(NcodeImageResizer.MODE) {
case 'none':
break;
case 'samewindow':
window.open(this.img.src, '_self');
break;
case 'newwindow':
window.open(this.img.src, '_blank');
break;
case 'enlarge':
default:
this.img.width = this.originalWidth;
this.img.height = this.originalHeight;
this.img.className = 'ncode_imageresizer_original';
if(this.warning != null) {
this.warningTextNode.data = NcodeImageResizer.Msg4;
this.warning.width = this.img.width;
this.warning.onclick = function() { return this.resize.scale() };
}
break;
}

return false;
}
 
2008-08-29 23:35:00
Group: Member
Posts: 1
Topics participated: 1
Topics started: 0
First post: 2008-08-29 23:35:00
Last post: 2008-08-29 23:35:00
It doesn't work on my site at all. Changed everything as they should and re-modified the files too after all the lines you've told, but without any luck at all.

Any suggestions that could be the reason why it doesn't work?

tags.php shows plain text of it, no picture at all.
Something that I've missed?


EDIT: NEVER MIND! Fixed it myself....
 
2008-11-19 15:27:00
Group: Member
Posts: 32
Topics participated: 15
Topics started: 8
First post: 2007-07-02 22:40:00
Last post: 2008-11-21 11:00:00
hello
i have a problem with this mod
I am did everything just like it says and i dont know where is the problem if anyone can help me
here is my

i put in bittorent the script tags
and in root the js file

main part for changing global.php, i did changes like xam said...
// Underline
$s = preg_replace("/\[u\]((\s|.)+?)\[\/u\]/", "\\1", $s);

// Underline
$s = preg_replace("/\[u\]((\s|.)+?)\[\/u\]/i", "\\1", $s);

// [img]http://www/image.gif[/img*]
$s = preg_replace("/\[img\](http:\/\/[^\s'\"<>]+(\.(jpg|gif|png)))\[\/img\]/i", "\"\"
This image has been resized, click here to view the full-sized image.

", $s);

// [img=http://www/image.gif]
$s = preg_replace("/\[img=(http:\/\/[^\s'\"<>]+(\.(gif|jpg|png)))\]/i", "\"\"", $s);

// Text
$s = preg_replace(
"/\+)\]((\s|.)+?)\[\/color\]/i",
"\\2", $s);

// [color=#ffcc99]Text

$s = preg_replace(
"/\[color=(#[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9])\]((\s|.)+?)\[\/color\]/i",
"\\2", $s);



Ok now i fixed this one
// [img]http://www/image.gif[/img*]

i just need to fix this
// [img=http://www/image.gif]
i use poster mod and only in Screenshots table in details.php the scren dont want to resize.. help
 
2008-12-01 17:32:00
Group: Member
Posts: 148
Topics participated: 92
Topics started: 40
First post: 2007-10-11 02:47:00
Last post: 2008-12-26 19:47:00
works a treat thanks ;)
 
2008-12-09 10:16:00
Group: Member
Posts: 502
Topics participated: 255
Topics started: 64
First post: 2007-10-08 19:40:00
Last post: 2009-01-03 21:49:00
Re-uploaded ncode...
 
2008-12-09 10:26:00
Group: Member
Posts: 577
Topics participated: 354
Topics started: 14
First post: 2008-03-01 01:47:00
Last post: 2009-01-03 16:33:00
already posted :)
4 posts above this one ^^
=]
 
2008-12-09 10:32:00
Group: Member
Posts: 502
Topics participated: 255
Topics started: 64
First post: 2007-10-08 19:40:00
Last post: 2009-01-03 21:49:00
A user requested it so i posted
 

Similar threads

Topic Posts Last post
Large Torrent Problem Please Help!! 3 2007-07-20 12:15:00
AutoResize large pictures 34 2008-05-24 04:31:00
problem with large .torrents 2 2008-09-28 14:56:00
1.77MB torrent file too large 13 2008-11-03 00:43:00
large torrents upload failure 2 2008-01-10 01:24:00