Offsite hosted Image resizing in e107 forums (Resolved)

e107 CMS » Forums » e107 v1.x Support » Core Code Support << Previous thread | Next thread >>
Go to page  1 2 3 ... 5 6 7 ... 9 10 11
Avocadoo
Aug 28 2007, 02:47AM
Registered Member #38672
Joined: Jul 28 2007, 07:23AM
Posts: 44
marj wrote ...

v0.7.8 [-link-]

Doesnt work me. I inserted a picture for test and the picture size was 1024*768. I changed the rate in img.bb to 400, but nothing happend. The picture was 1024 width
Go to top
marj
Aug 28 2007, 11:04AM
marj
Registered Member #1159
Joined: Mar 16 2003, 08:00AM
Posts: 6161
should work.
did you placed it in e107_files/bbcodes?
Go to top
Avocadoo
Aug 28 2007, 10:28PM
Registered Member #38672
Joined: Jul 28 2007, 07:23AM
Posts: 44
marj wrote ...

should work.
did you placed it in e107_files/bbcodes?

Yes sure after i placed the new img.bb i linked a test image in my forum, but nothing happened. I dont know whats the problem, because my friend try this bb code on his site and doesnt work for him. Maybe need other settings in admin menu? (Can i get a url, where i see when its woorking? Sorry my english)

I have 0.7.8 - Hungarian - 8859-2 ISO version

Thx for all e107 user whos try to help me. Thx.
[ Edited Aug 29 2007, 01:04AM ]
Go to top
Avocadoo
Aug 29 2007, 06:05AM
Registered Member #38672
Joined: Jul 28 2007, 07:23AM
Posts: 44
Yes! Work with a other img.bb and a .js file, because my friend made something. But i cant upload because i am not at home. I will upload tonight, or tomorrow.
Go to top
Avocadoo
Aug 29 2007, 11:09PM
Registered Member #38672
Joined: Jul 28 2007, 07:23AM
Posts: 44
Here is a other image resizer for your forum:

Download the file

Made by Lac: Hungarian e107 community
[ Edited Aug 29 2007, 11:10PM ]
Go to top
C6Dave
Aug 30 2007, 12:46AM
  • e107 Site administrator
  • e107 Support Team Leader
Registered Member #9506
Joined: Jul 31 2004, 12:57AM
Location: North East UK
Posts: 12343
Avacado that hack gives an [image disabled] message for me on test??
Go to top
Website
marj
Aug 30 2007, 01:57AM
marj
Registered Member #1159
Joined: Mar 16 2003, 08:00AM
Posts: 6161
2dopey wrote ...

Avacado that hack gives an [image disabled] message for me on test??

probably line 47 of this img.bb:
if (check_class($pref[''],$uc)) {

should be:
if (check_class($pref['image_post_class'],$uc)) {

there's some other slighty differences with the original img.bb which could affect some dedicated settings. not sure of this last point anyway
Go to top
Avocadoo
Aug 30 2007, 02:37AM
Registered Member #38672
Joined: Jul 28 2007, 07:23AM
Posts: 44
When a member insterted a pic on my forum, the e107 system wrote: IMAGE DISABLE
It was good after delete something in img.bb.

original: In img.bb look at line 46: if (check_class($pref['image_post_class'],$uc)) {
modifed: You can just remove the class completely: if (check_class($pref[''],$uc)) {

When i delete the 'image_post_class' the pics are in forum, and not more IMAGE DISABLE BLA BLA...


[ Edited Aug 30 2007, 02:41AM ]
Go to top
marj
Aug 30 2007, 02:54AM
marj
Registered Member #1159
Joined: Mar 16 2003, 08:00AM
Posts: 6161
wrong analysis
$pref['image_post_class'] is a core pref admin > images
should be there for those who wants too

if you don't want to use it in your img.bb, simply delete the test
check_class($pref[''],$uc) can't return something correct
Go to top
dave_soton
Sep 12 2007, 10:59AM
Registered Member #37000
Joined: Jun 03 2007, 04:06AM
Posts: 34
I just installed the js version and works fantastic on 7.8! Thanks guys! Love the ability to click for a full sized image but might try to hack it so the image is a link too.

Great work guys!! This really should atleast be in the next release as an option!

Thank you 2dopey for pointing me to it
Go to top
HoriZon
Oct 12 2007, 03:09PM
Registered Member #35162
Joined: Apr 13 2007, 06:21AM
Location: UK
Posts: 162
This no longer works for offsite images for me.

It worked after i updated to 0.7.9, as i re-added the hack! and tested it. But not today.

It does work if i add an image on my site and use http://e107.org/e107_images/ but not if i use http://etc...

Same for both IE7 and FF2 with admin account or nomral account.



Maybe a PHP update or somthing has broke it ?

-- phpMyAdmin SQL Dump
-- version 2.11.0
--
-- Host: localhost
-- Generation Time: Oct 13, 2007 at 01:16 AM
-- Server version: 4.1.22
-- PHP Version: 5.2.3


It has changed from a view days ago its on a newer version now.

-- phpMyAdmin SQL Dump
-- version 2.10.0.2
--
-- Host: localhost
-- Generation Time: Oct 10, 2007 at 04:43 PM
-- Server version: 4.1.22
-- PHP Version: 4.4.4





Can someone add the edited file and post it here for 0.7.9 plz?
[ Edited Oct 12 2007, 05:26PM ]
Go to top
Website
thuro
Oct 12 2007, 04:14PM
Registered Member #32513
Joined: Nov 22 2006, 01:10PM
Posts: 103
worked for me in 7.9
Go to top
Chris Powell
Nov 02 2007, 07:43AM
Registered Member #39978
Joined: Sep 17 2007, 10:13AM
Location: United Kingdom
Posts: 703
im using 0.7.10 and just tried this code
global $pref;
if (preg_match("#\.php\?.*#",$code_text)){return "";}
global $IMAGES_DIRECTORY, $FILES_DIRECTORY, $e107;
$search = array('"', '{E_IMAGE}', '{E_FILE}');
$replace = array(''', $e107->base_path.$IMAGES_DIRECTORY, $e107->base_path.$FILES_DIRECTORY);
$code_text = str_replace($search, $replace, $code_text);
unset($imgParms);
$imgParms['class']="bbcode";
$imgParms['alt']='';
$imgParms['style']="vertical-align:middle; border:0";

$code_text = $tp -> toAttribute($code_text);

if($parm) {
$parm = preg_replace('#onerror *=#i','',$parm);
$parm = str_replace("amp;", "&", $parm);
parse_str($parm,$tmp);
foreach($tmp as $p => $v) {
$imgParms[$p]=$v;
}
}
$parmStr="";

foreach($imgParms as $k => $v) {
$parmStr .= $tp -> toAttribute($k)."='".$tp -> toAttribute($v)."' ";
}


if(file_exists(e_IMAGE."newspost_images/".$code_text))
{
$code_text = e_IMAGE."newspost_images/".$code_text;
}
// add
$resizeme = resizeme ($code_text);
$resizeme_prefix ='';
$resizeme_postfix='';
if ($resizeme != false) {
$resizeme_prefix .= "<a href='$code_text' rel='external'>";
$parmStr .= $resizeme;
$resizeme_postfix .= "</a>";
}
function resizeme ($code_text) {
$size = getimagesize($code_text);
if ($size !== false) {
$w = $size[0];
$h = $size[1];
$maxW = 595 ; // edited 595 in place of 100
if ($w > $maxW) {
$h = intval($h / ($w/$maxW));
$w = $maxW;
$parmStr .= " width='$w' height='$h'";
return $parmStr;
}
}
return false;
}
// end add

if (!$postID) {
return $resizeme_prefix."<img src='".$code_text."' {$parmStr} />".$resizeme_postfix; //add
} else {
if(strstr($postID,'class:')) {
$uc = substr($postID,6);
}
if ($pref['image_post']) {
if($uc == '') {
if (!function_exists('e107_userGetuserclass')) {
require_once(e_HANDLER.'user_func.php');
}
$uc = e107_userGetuserclass($postID);
}
if (check_class($pref['image_post_class'],$uc)) {
return $resizeme_prefix."<img src='".$code_text."' {$parmStr} />".$resizeme_postfix; // add
}
else
{
return ($pref['image_post_disabled_method'] ? "[ image disabled ]" : "Image: $code_text");
}
}
else
{
if ($pref['image_post_disabled_method']) {
return '[ image disabled ]';
} else {
return "Image: $code_text";
}
}
}


but no good. what is the latest code please...?
Go to top
Website
theDude
Nov 14 2007, 04:53PM
Registered Member #6328
Joined: Feb 12 2004, 08:20AM
Location: Goose Creek, USA
Posts: 785
[quote]
Well php is vers 4.4.2 but Marj's final edit did the trick and it works beautifully

Thanks for the help guys - I'll mark this as resolved for future reference

For everyone else - In admin/files/bbcode/img.bb copy the code below and at line 33 insert it and save the file
if (function_exists("getimagesize")) {
$size = getimagesize($code_text);
if ($size !== false) {
$w = $size[0];
$h = $size[1];
$maxW = 595;
if ($w > $maxW) {
$h = intval($h / ($w/$maxW));
$w = $maxW;
}
$parmStr .= " width='$w' height='$h'";
}
}


This then auto resizes any offsite hosted image to a maximum width of 595 pixels (edit 595 to suit your own theme) with the height auto resizing in proportion to the original

Then you simply wrap the url with bbcode [img] tags
[/quote1195087757]
I realize this is an old post, BUT it did fix one of my problems...but if I resize my browser to 800x600, the image doesn't resize with it, it stays at 500px (I changed the 595 to 500 because it would still overflow into the right menu area at 1024x768). Is that a theme related issue? or still something with img.bb? Is it a gd2 server side issue? thanks!
[ Edited Nov 14 2007, 04:55PM ]
Go to top
Yahto
Nov 29 2007, 11:15AM
Registered Member #41532
Joined: Nov 27 2007, 03:19AM
Posts: 4
So there is no definite solution for this problem? None of the solutions work for me in 7.10, but I could be going about it incorrectly.
Go to top
dave_soton
Dec 03 2007, 05:31AM
Registered Member #37000
Joined: Jun 03 2007, 04:06AM
Posts: 34
I'm now running 7.10 without any problems with the .js resize mod(resizer_hax.zip). And a modified img.bb like so:

global $pref;
if (preg_match("#\.php\?.*#",$code_text)){return "";}
global $IMAGES_DIRECTORY, $FILES_DIRECTORY, $e107;
$search = array('"', '{E_IMAGE}', '{E_FILE}', 'http://e107.org/e107_images/', 'http://e107.org/e107_files/');
$replace = array(''', $e107->base_path.$IMAGES_DIRECTORY, $e107->base_path.$FILES_DIRECTORY, $e107->base_path.$IMAGES_DIRECTORY, $e107->base_path.$FILES_DIRECTORY);
$code_text = str_replace($search, $replace, $code_text);
unset($imgParms);
$imgParms['class']="bbcode";
$imgParms['alt']='';
$imgParms['style']="vertical-align:middle; border:0";


$code_text = $tp -> toAttribute($code_text);

if($parm) {
$parm = preg_replace('#onerror *=#i','',$parm);
$parm = str_replace("amp;", "&", $parm);
parse_str($parm,$tmp);
foreach($tmp as $p => $v) {
$imgParms[$p]=$v;
}
}
$parmStr="";
foreach($imgParms as $k => $v) {
$parmStr .= $tp -> toAttribute($k)."='".$tp -> toAttribute($v)."' ";
}


if((strpos($code_text,'../') === FALSE) && file_exists(e_IMAGE."newspost_images/".$code_text))
{
$code_text = e_IMAGE."newspost_images/".$code_text;
}

if (!$postID) {
return "<div class='linked-images'><img onLoad='_resize(this);' src='".$code_text."' {$parmStr} /></div>";
} else {
if(strstr($postID,'class:')) {
$uc = substr($postID,6);
}
if ($pref['image_post']) {
if(!isset($uc) || ($uc == '')) {
if (!function_exists('e107_userGetuserclass')) {
require_once(e_HANDLER.'user_func.php');
}
$uc = e107_userGetuserclass($postID);
}
if (check_class($pref['image_post_class'],$uc)) {
return "<div class='linked-image'><img onLoad='_resize(this);' src='".$code_text."' {$parmStr} /></div>";
}
else
{
return ($pref['image_post_disabled_method'] ? "[ image disabled ]" : "Image: $code_text");
}
}
else
{
if ($pref['image_post_disabled_method']) {
return '[ image disabled ]';
} else {
return "Image: $code_text";
}
}
}


Works just as well as it did before but I had to modify the above file to get it to work in version 10 release as this broke it and even the original resizer file didnt work either. Cant remember what I changed but I think its just on variable isnt defined or requested in the code somewhere thats required for version 10.
Go to top
Yahto
Dec 04 2007, 06:51AM
Registered Member #41532
Joined: Nov 27 2007, 03:19AM
Posts: 4
Where is this .js resizer mod available? If it's the filefactory link on this page, the file expired.
Go to top
dave_soton
Dec 04 2007, 12:01PM
Registered Member #37000
Joined: Jun 03 2007, 04:06AM
Posts: 34
The contents of the theme.js that needs to be added to yours is the following but do remember it is not my mod and thanks should be given to the writer. I will say it seems to intermittant not display pics too so if anyone finds the solution to this then place post

//IMAGE RESIZING
confMaxDim = 350; // in pixel

function _resize(obj) {
imgStaticWidth = obj.width;
thisWidth = obj.width;
thisHeight = obj.height;

if(thisWidth > thisHeight) thisMaxDim = thisWidth;
else thisMaxDim = thisHeight;

if(thisMaxDim > confMaxDim) {
thisMinDim = Math.round((((thisWidth > thisHeight)?thisHeight:thisWidth) * confMaxDim) / thisMaxDim);

if(thisWidth > thisHeight) {
thisWidth = confMaxDim;
thisHeight = thisMinDim;
} else {
thisHeight = confMaxDim;
thisWidth = thisMinDim;
}
} // if(thisMaxDim > confMaxDim)

obj.height = thisHeight;
obj.width = thisWidth;

if(imgStaticWidth > confMaxDim){
bottomPara = document.createElement('p');
bottomPara.setAttribute('style', 'text-align: center;width:' + obj.width + 'px;');
bottomPara.setAttribute('class', 'resizedImageLink');
bottomPara.innerHTML = '<a href="'+ obj.src +'" rel="external">Klick here for original size</a>';
obj.parentNode.appendChild(bottomPara);
}
}

Go to top
archeens
Dec 22 2007, 02:40PM
Registered Member #27220
Joined: May 04 2006, 10:23AM
Posts: 41
Im using Version 0.7.10 and when i replace img.bb with this code

global $pref;
if (preg_match("#\.php\?.*#",$code_text)){return "";}
global $IMAGES_DIRECTORY, $FILES_DIRECTORY, $e107;
$search = array('"', '{E_IMAGE}', '{E_FILE}', 'http://e107.org/e107_images/', 'http://e107.org/e107_files/');
$replace = array(''', $e107->base_path.$IMAGES_DIRECTORY, $e107->base_path.$FILES_DIRECTORY, $e107->base_path.$IMAGES_DIRECTORY, $e107->base_path.$FILES_DIRECTORY);
$code_text = str_replace($search, $replace, $code_text);
unset($imgParms);
$imgParms['class']="bbcode";
$imgParms['alt']='';
$imgParms['style']="vertical-align:middle; border:0";


$code_text = $tp -> toAttribute($code_text);

if($parm) {
$parm = preg_replace('#onerror *=#i','',$parm);
$parm = str_replace("amp;", "&", $parm);
parse_str($parm,$tmp);
foreach($tmp as $p => $v) {
$imgParms[$p]=$v;
}
}
$parmStr="";
foreach($imgParms as $k => $v) {
$parmStr .= $tp -> toAttribute($k)."='".$tp -> toAttribute($v)."' ";
}


if((strpos($code_text,'../') === FALSE) && file_exists(e_IMAGE."newspost_images/".$code_text))
{
$code_text = e_IMAGE."newspost_images/".$code_text;
}

if (!$postID) {
return "<div class='linked-images'><img onLoad='_resize(this);' src='".$code_text."' {$parmStr} /></div>";
} else {
if(strstr($postID,'class:')) {
$uc = substr($postID,6);
}
if ($pref['image_post']) {
if(!isset($uc) || ($uc == '')) {
if (!function_exists('e107_userGetuserclass')) {
require_once(e_HANDLER.'user_func.php');
}
$uc = e107_userGetuserclass($postID);
}
if (check_class($pref['image_post_class'],$uc)) {
return "<div class='linked-image'><img onLoad='_resize(this);' src='".$code_text."' {$parmStr} /></div>";
}
else
{
return ($pref['image_post_disabled_method'] ? "[ image disabled ]" : "Image: $code_text");
}
}
else
{
if ($pref['image_post_disabled_method']) {
return '[ image disabled ]';
} else {
return "Image: $code_text";
}
}
}





i get this error:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in C:\wamp\www\e107_handlers\bbcode_handler.php(296) : eval()'d code on line 8

what is the problem?
Go to top
Amelek
Feb 20 2008, 03:30PM
Registered Member #6136
Joined: Feb 04 2004, 01:15PM
Posts: 7
Finally im begining to understand something. Got my pictures to show now in 0.7.11.

global $pref;
if (preg_match("#\.php\?.*#",$code_text)){return "";}
global $IMAGES_DIRECTORY, $FILES_DIRECTORY, $e107;
$search = array('"', '{E_IMAGE}', '{E_FILE}', 'http://e107.org/e107_images/', 'http://e107.org/e107_files/');
$replace = array(''', $e107->base_path.$IMAGES_DIRECTORY, $e107->base_path.$FILES_DIRECTORY, $e107->base_path.$IMAGES_DIRECTORY, $e107->base_path.$FILES_DIRECTORY);
$code_text = str_replace($search, $replace, $code_text);
unset($imgParms);
$imgParms['class']="bbcode";
$imgParms['alt']='';

$code_text = $tp -> toAttribute($code_text);

if($parm)
{
$parm = preg_replace('#onerror *=#i','',$parm);
$parm = str_replace("amp;", "&", $parm);
parse_str($parm,$tmp);
foreach($tmp as $p => $v)
{
$imgParms[$p]=$v;
}
}
$parmStr="";
foreach($imgParms as $k => $v)
{
$parmStr .= $tp -> toAttribute($k)."='".$tp -> toAttribute($v)."' ";
}


if((strpos($code_text,'../') === FALSE) && file_exists(e_IMAGE."newspost_images/".$code_text))
{
$code_text = e_IMAGE."newspost_images/".$code_text;
}
if (function_exists("getimagesize")) {
$size = getimagesize($code_text);
if ($size !== false) {
$w = $size[0];
$h = $size[1];
$maxW = 480;
if ($w > $maxW) {
$h = intval($h / ($w/$maxW));
$w = $maxW;
}
$parmStr .= " width='$w' height='$h'";
}
}
if (!$postID || $postID == 'admin')
{
return "<img src='".$code_text."' {$parmStr} />";
}
else
{
if(strstr($postID,'class:'))
{
$uc = substr($postID,6);
}
if ($pref['image_post'])
{
if(!isset($uc) || ($uc == ''))
{
if (!function_exists('e107_userGetuserclass'))
{
require_once(e_HANDLER.'user_func.php');
}
$uc = e107_userGetuserclass($postID);
}
if (check_class($pref['image_post_class'],$uc))
{
return "<img src='".$code_text."' {$parmStr} />";
}
else
{
return ($pref['image_post_disabled_method'] ? "[ image disabled ]" : "Image: $code_text");
}
}
else
{
if ($pref['image_post_disabled_method'])
{
return '[ image disabled ]';
}
else
{
return "Image: $code_text";
}
}
}

It does a great job in resizing linked pictures...but one thing i still miss is to be able to klick on the picture and look at the unresized one...

EDIT Scratch that, just found Marj's fix a few posts back. Made for version 0.7.8, works fine with 0.7.11.
[ Edited Feb 20 2008, 03:40PM ]
Go to top
Go to page  1 2 3 ... 5 6 7 ... 9 10 11  

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System