Jump to content

multiple image resize in comments! i'll explain!


droopz17

Recommended Posts

I want to have all images hotlinked to be resized if they are bigger than ( let's say 500 ) so that it won't distort my layout. Now here's the tricky part. It's basically a comment and I have it set up where they put [  img  ]  url  [ /  img  ]    of course without the spaces.

 

Here what i want. I want it to go through the whole comment and take the image tag and determine the size and if it's bigger than my chosen size then add a width size to the img src tag. but i want it so they can hotlink as many images as they would like.  exp below.

 

pretend images:      http://whatever.jpg      ( lets say size is 600 )

                          http://whatever2.jpg      (lets say size is 400 )

 

pretend comment below:------------------------------------------

 

hey man check out this image i found

[  img  ]  http://whatever.jpg  [/  img ]

 

oh and this one too!

 

[ img ] http://whatever2.jpg  [ / img ]

 

k man hit me back

 

------------------------------------------------------------------

 

 

and i want it to show the comment and images all at the same time and if they had to be resized then the script took care of it.

 

I've tried everything i can think of....  Please help!!!

Link to comment
Share on other sites

You could pass the image to a calling script that would check for size then ech out the correct image stream.

 

A bit like:

 

[ img ] <? handleImage.php?img=whatever.jpg; ?> [ img ]

 

Then in the calling script you do all the size checks then echo out the final image.

Link to comment
Share on other sites

You could pass the image to a calling script that would check for size then ech out the correct image stream.

 

A bit like:

 

[ img ] <? handleImage.php?img=whatever.jpg; ?> [ img ]

 

Then in the calling script you do all the size checks then echo out the final image.

 

Thanks for the great idea! i'll try it and see what i come up with.

Link to comment
Share on other sites

K I tried your idea and i thought it was going to work great but unfortunately it did not work...  at least not yet. Below is the code that i have and the result it gives me. And yes! I already tried eval() to try and get the code to execute as php code instead of it treating it as a string but it still doesn't work. Please help!!!

 

$get_profile_comments_q = mysql_query( $get_profile_comments );
$get_profile_comments_nr = mysql_num_rows( $get_profile_comments_q );
if( $get_profile_comments_nr > 0 ){
while( $get_profile_comments_a = mysql_fetch_array( $get_profile_comments_q ) ){
	$comment = $get_profile_comments_a['pro_com_comment'];

	$img = str_replace( " [ img ]", "<?php include('image_handler.php?image= ", $comment );
	$img = str_replace( "[ /img ]", " '); ?>", $img );
	//echo eval("?>".$img);    //tried this like a ton of different ways.
	echo '
	<tr>
		<td>
			<table width="100%" border="0" cellspacing="2" cellpadding="5" class="maintext3">
				<tr>
					<td align="center" width="125">'.$get_profile_comments_a['user'].'</td>
					<td width="575">'.$get_profile_comments_a['pro_com_date'].'</td>
				</tr>
				<tr>
					<td align="center" valign="top"><img src="'.$get_profile_comments_a['picture'].'" border="0" class="photo"></td>
					<td>'.$img.'</td>
				</tr>
			</table>
		</td>
	</tr>';

}
}

 

and blow is what i get if i view the page source.

 

<td><?php include('image_handler.php?image= www.onflex.org/images/iceberg.jpg '); ?></td>

 

as you can see it's just printing out the php line instead of executing it.

Link to comment
Share on other sites

Hi,

 

Well, my idea was to use the calling script to echo out the image not to replace current variables.

 

<?php
$img='myimage.jpg';
?>

Then in your html:

[ img]<?php include('image_handler.php?image='.$img); ?>[ /img]

 

Then your image_handler script would do something like:

<?php
$img=$_GET['image'];
.
//Do image manipulation stuff here
.
echo '<img src=images/'.$newimage.'/>';
?>

 

I've never done this but I was hoping it would point you in some kind of direction!

Good luck! :)

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.