simcoweb Posted October 3, 2006 Share Posted October 3, 2006 I have a page displaying member profiles along with a photo of each. I'd like the photos to be able to be displayed in various sizes throughout the site but don't want to create multiple images of each to do so. I have this function that resizes but the method it's using is by actually naming the image you want resized. Instead I want it to extract the image name from the database then display the resized image in the page where I have the <img src tag. Here's the function code:[code]<?phpfunction imageResize($width, $height, $target) {//takes the larger size of the width and height and applies the formula accordingly...this is so this script will work dynamically with any size imageif ($width > $height) {$percentage = ($target / $width);} else {$percentage = ($target / $height);}//gets the new value and applies the percentage, then rounds the value$width = round($width * $percentage);$height = round($height * $percentage);//returns the new sizes in html image tag format...this is so youcan plug this function inside an image tag and just get thereturn "width=\"$width\" height=\"$height\"";}?>[/code]Which uses this variable:[code]$myphoto = getimagesize("images/photo/imagename001.jpg");[/code]In order to get the current image size/dimensions.Here's the HTML tag suggested:[code]<img src="images/photo/image001.jpg" <?php imageResize($myphoto[0], $myphoto[1], 150); ?>[/code]My problem is that the name of the image is not known. Therefore I can't set that $myphoto variable. In my case the name of the image needs to come from a mysql query which returns the information from a field labeled 'photo'. The page will display several profiles per page. Therefore the image needs to be relevant to the profiles being shown. Right now the profiles are fine as far as displaying them in the proper order, etc. The only issue is the image resizing per image displayed.Help? Quote Link to comment Share on other sites More sharing options...
simcoweb Posted October 3, 2006 Author Share Posted October 3, 2006 *little bump* :) Quote Link to comment Share on other sites More sharing options...
simcoweb Posted October 4, 2006 Author Share Posted October 4, 2006 Anyone? :( Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.