Image Resize PHP Code for Wordpress

Discussion in 'Programming' started by vinny, Jun 27, 2008.

  1. #1
    //create the resize function
    function imageResize($width, $height, $target)


    {
    $percentage = ($target / $width);


    $width = round($width * $percentage);


    $height = round($height * $percentage);


    return "width=\"$width\" height=\"$height\"";


    }

    //get the size of the image
    $image = getimagesize($row['upload_url']);


    if ($image[0] > "650") // if the image width is greater than "650" image[0] is width, image[1] is height


    {
    echo "<img src=\"path/to/image.jpg\" ".imageResize($image[0], $image[1], 650).">";


    // get the image width and height, and compare it to your target width or height.
    {
    else


    {
    echo "<img src=\"path/to/image.jpg\">";


    // display the regular image"

    Using that PHP code, I want every image in the <div> with the class .entry to be resized if its more than 500px wide.

    Need this integrated into a wordpress blog

    please reply with a quote.
     
    vinny, Jun 27, 2008 IP
  2. NetworkTown.Net

    NetworkTown.Net Well-Known Member

    Messages:
    2,022
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    165
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    $15 by paypal.
     
    NetworkTown.Net, Jun 28, 2008 IP
  3. cr0n1cal

    cr0n1cal Active Member

    Messages:
    287
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    $14 if it's available :D
     
    cr0n1cal, Jun 28, 2008 IP
  4. clarky_y2k3

    clarky_y2k3 Well-Known Member

    Messages:
    114
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    108
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    I can do it for $12. :)
     
    clarky_y2k3, Jun 28, 2008 IP
  5. vinny

    vinny Peon

    Messages:
    268
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5
    thanks for the responses guys, this is what i need,



    The PHP code should be the same that picresize.com is using, their code doesnt diminish the quality of the picture.

    images that are greater than 500px W to be resized to 500px W, the Height needs to be adjusted at the same proportions /ration

    then i also need smaller images that are less than 500px W to be centered around a 500px / 500px border.

    Thanks for the responses, need this done asap.
     
    vinny, Jun 28, 2008 IP
  6. clarky_y2k3

    clarky_y2k3 Well-Known Member

    Messages:
    114
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    108
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #6
    I can do that for all images posted within a blog or page automatically.
     
    clarky_y2k3, Jun 28, 2008 IP