Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    May 2011
    Posts
    33
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Word Press PhP edit help

    Hey so I have this word press theme and I need to edit a template file...

    Pretty much its a portfolio file template and i need to make it so the image i place on the page can be any size
    This is what I have but the only size the image can be is
    1800x431

    I need that number to be flexible or have another if statement saying if the image is this 10x10 make it show up 10x10 else the image is 30x30 make it show up 30x30...
    preferable it would be better to make it be any size does anyone know how to fix this?
    Code:
    <div class="content_block">
                                <div class="pf-box-view">
                                <?php if (function_exists('has_post_thumbnail') && has_post_thumbnail()) {?>
                                <a href="<?php echo ($pf_link) ? $pf_link : thumb_url();?>" rel="prettyPhoto[portfolio]">
                                  <img src="<?php bloginfo('template_directory');?>/timthumb.php?src=<?php echo thumb_url();?> &amp;h=1800&amp;w=431&amp;zc=1 alt="" />                      
                                </a>                            
                                <?php } else {
                                  if ($pf_thumb) { ?>
                                  <a href="<?php echo ($pf_link) ? $pf_link : thumb_url();?>" rel="prettyPhoto[portfolio]">
                                    <img src="<?php bloginfo('template_directory');?>/timthumb.php?src=<?php echo $pf_thumb;?>&amp;h=1800&amp;w=431&amp;zc=1 alt="" class="pf-img alignleft" />
                                  </a>
                                <?php }
                                  }
                                ?>
                                </div>

  • #2
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,386
    Thanks
    8
    Thanked 1,077 Times in 1,068 Posts
    You have a script in your theme directory called: timthumb.php

    Post that script for us.
    I think that is where the image manipulation will be done.

    I assume you've already tried changing these values?
    &amp;h=1800&amp;w=431

    and that didn't work.

    It still shows up as 1800X431 no matter what you make those values?


    .

  • #3
    New Coder
    Join Date
    May 2011
    Posts
    33
    Thanks
    2
    Thanked 0 Times in 0 Posts
    well I completely took out that value... now that i took that out they show up as 100x100 by default so im guessing i need to find something similar to what i took out of the posting earlier...

  • #4
    New Coder
    Join Date
    May 2011
    Posts
    33
    Thanks
    2
    Thanked 0 Times in 0 Posts
    here is timthumb
    i think i need to change this...

    Code:
    // get standard input properties
    $new_width =  (int) abs (get_request ('w', 0));
    $new_height = (int) abs (get_request ('h', 0));
    $zoom_crop = (int) get_request ('zc', 1);
    $quality = (int) abs (get_request ('q', 90));
    $align = get_request ('a', 'c');
    $filters = get_request ('f', '');
    $sharpen = (bool) get_request ('s', 0);
    
    // set default width and height if neither are set already
    if ($new_width == 0 && $new_height == 0) {
        $new_width = 100;
        $new_height = 100;
    }
    
    // ensure size limits can not be abused
    $new_width = min ($new_width, MAX_WIDTH);
    $new_height = min ($new_height, MAX_HEIGHT);
    
    // set memory limit to be able to have enough space to resize larger images
    ini_set ('memory_limit', MEMORY_LIMIT);
    
    if (file_exists ($src)) {
    
        // open the existing image
        $image = open_image ($mime_type, $src);
        if ($image === false) {
            display_error ('Unable to open image : ' . $src);
        }
    
        // Get original width and height
        $width = imagesx ($image);
        $height = imagesy ($image);
    	$origin_x = 0;
    	$origin_y = 0;
    
        // generate new w/h if not provided
        if ($new_width && !$new_height) {
            $new_height = floor ($height * ($new_width / $width));
        } else if ($new_height && !$new_width) {
            $new_width = floor ($width * ($new_height / $height));
        }
    
    	// scale down and add borders
    	if ($zoom_crop == 3) {
    
    		$final_height = $height * ($new_width / $width);
    
    		if ($final_height > $new_height) {
    			$new_width = $width * ($new_height / $height);
    		} else {
    			$new_height = $final_height;
    		}
    
    	}
    
    	// create a new true color image
    	$canvas = imagecreatetruecolor ($new_width, $new_height);
    	imagealphablending ($canvas, false);
    
    	// Create a new transparent color for image
    	$color = imagecolorallocatealpha ($canvas, 0, 0, 0, 127);
    
    	// Completely fill the background of the new image with allocated color.
    	imagefill ($canvas, 0, 0, $color);
    
    	// scale down and add borders
    	if ($zoom_crop == 2) {
    
    		$final_height = $height * ($new_width / $width);
    		
    		if ($final_height > $new_height) {
    			
    			$origin_x = $new_width / 2;
    			$new_width = $width * ($new_height / $height);
    			$origin_x = round ($origin_x - ($new_width / 2));
    
    		} else {
    
    			$origin_y = $new_height / 2;
    			$new_height = $final_height;
    			$origin_y = round ($origin_y - ($new_height / 2));
    
    		}
    
    	}
    
    	// Restore transparency blending
    	imagesavealpha ($canvas, true);
    
    	if ($zoom_crop > 0) {
    
    		$src_x = $src_y = 0;
    		$src_w = $width;
    		$src_h = $height;
    
    		$cmp_x = $width / $new_width;
    		$cmp_y = $height / $new_height;
    
    		// calculate x or y coordinate and width or height of source
    		if ($cmp_x > $cmp_y) {
    
    			$src_w = round ($width / $cmp_x * $cmp_y);
    			$src_x = round (($width - ($width / $cmp_x * $cmp_y)) / 2);
    
    		} else if ($cmp_y > $cmp_x) {
    
    			$src_h = round ($height / $cmp_y * $cmp_x);
    			$src_y = round (($height - ($height / $cmp_y * $cmp_x)) / 2);
    
    		}
    
    		// positional cropping!
    		if ($align) {
    			if (strpos ($align, 't') !== false) {
    				$src_y = 0;
    			}
    			if (strpos ($align, 'b') !== false) {
    				$src_y = $height - $src_h;
    			}
    			if (strpos ($align, 'l') !== false) {
    				$src_x = 0;
    			}
    			if (strpos ($align, 'r') !== false) {
    				$src_x = $width - $src_w;
    			}
    		}
    
    		imagecopyresampled ($canvas, $image, $origin_x, $origin_y, $src_x, $src_y, $new_width, $new_height, $src_w, $src_h);
    
        } else {
    
            // copy and resize part of an image with resampling
            imagecopyresampled ($canvas, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
    
        }
    
        if ($filters != '' && function_exists ('imagefilter') && defined ('IMG_FILTER_NEGATE')) {
            // apply filters to image
            $filterList = explode ('|', $filters);
            foreach ($filterList as $fl) {
    
                $filterSettings = explode (',', $fl);
                if (isset ($imageFilters[$filterSettings[0]])) {
    
                    for ($i = 0; $i < 4; $i ++) {
                        if (!isset ($filterSettings[$i])) {
    						$filterSettings[$i] = null;
                        } else {
    						$filterSettings[$i] = (int) $filterSettings[$i];
    					}
                    }
    
                    switch ($imageFilters[$filterSettings[0]][1]) {
    
                        case 1:
    
                            imagefilter ($canvas, $imageFilters[$filterSettings[0]][0], $filterSettings[1]);
                            break;
    
                        case 2:
    
                            imagefilter ($canvas, $imageFilters[$filterSettings[0]][0], $filterSettings[1], $filterSettings[2]);
                            break;
    
                        case 3:
    
                            imagefilter ($canvas, $imageFilters[$filterSettings[0]][0], $filterSettings[1], $filterSettings[2], $filterSettings[3]);
                            break;
    
                        case 4:
    
                            imagefilter ($canvas, $imageFilters[$filterSettings[0]][0], $filterSettings[1], $filterSettings[2], $filterSettings[3], $filterSettings[4]);
                            break;
    
                        default:
    
                            imagefilter ($canvas, $imageFilters[$filterSettings[0]][0]);
                            break;
    
                    }
                }
            }
        }
    
    	// sharpen image
    	if ($sharpen && function_exists ('imageconvolution')) {
    
    		$sharpenMatrix = array (
    			array (-1,-1,-1),
    			array (-1,16,-1),
    			array (-1,-1,-1),
    		);
    
    		$divisor = 8;
    		$offset = 0;
    
    		imageconvolution ($canvas, $sharpenMatrix, $divisor, $offset);
    
    	}
    
        // output image to browser based on mime type
        show_image ($mime_type, $canvas);
    
        // remove image from memory
        imagedestroy ($canvas);
    
    	// if not in cache then clear some space and generate a new file
    	clean_cache ();
    
    	die ();
    
    } else {
    
        if (strlen ($src)) {
            display_error ('image ' . $src . ' not found');
        } else {
            display_error ('no source specified');
        }
    
    }
    how can i take that out so it just makes it the size the pictures the same as uploaded?
    Last edited by wdlax11; 02-17-2012 at 07:57 PM.

  • #5
    New Coder
    Join Date
    May 2011
    Posts
    33
    Thanks
    2
    Thanked 0 Times in 0 Posts
    This is what im working on..

    http://countrysweets.net/testing/?page_id=48

    I need the pictures to be their normal sizes.... not shrunk or auto fitted..
    Last edited by wdlax11; 02-17-2012 at 07:54 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •