ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

image resizing problem

November 25, 2008 4:06pm

Subscribe [2]
  • #1 / Nov 25, 2008 4:06pm

    Boxhead

    13 posts

    I’ve been trying to implement

    <?php
    $path = "{image}";
    list($width, $height) = getimagesize($path);
    
    echo $height;
    
    if($height > "350"){ 
    echo "{<div class='image'>{exp:imgsizer:size src='{image}' width='575' height='350' alt='{title}' title='{title}' >}";
    } else { 
    echo "{<div class='image'>{exp:imgsizer:size src='{image}' width='575' alt='{title}' title='{title}' >}"; 
    }
    ?>

    but to no avail.

    PHP is set to parse on input of the template and i get an error saying:

    Warning: getimagesize(http://www.example.co.uk/images/example.jpg) [function.getimagesize]: failed to open stream: No such file or directory in /core/core.functions.php(637) : eval()‘d code on line 27

    line 27 is

    list($width, $height) = getimagesize($path);
  • #2 / Nov 25, 2008 6:43pm

    Mark Bowen

    12637 posts

    Hiya,

    Just wondering where you are getting the {image} variable from? If you try this with the image URL hard-coded then it should work so probably a parsing issue I would suspect?

    That said I wouldn’t have expected that error. Have you tried using the Image Sizer Plugin on a template without any PHP and just see that it works by itself anyway?

    Best wishes,

    Mark

  • #3 / Nov 25, 2008 8:26pm

    Boxhead

    13 posts

    Hi Mark,

    Thanks for your help with this, the {image} variable is a custom field set in the weblog.
    When I upload an image file through the EE upload window, i set it to enter the url into that {image} field.

    I’m assuming the php is parsing it correctly as with each entry in the weblog i’m given the error message with the differing url’s to the .jpg files.

    The Image Sizer Plugin definitely works. Here is what i’m working on. You’ll notice that the two images (one for each post) are cropped down to 575px x 250px. The first image (with the guitar player) was originally about 1024 x 650 (so is cropped as i expect Imager Sizer to do it).
    The second image of the people in africa was originally about 425 x 235. This image is scaled up to the width=“575” height=“250” parameters in Image Sizer.

    What i want it to do is not scale up the images (like the second one) whose dimensions are anything below 575 x 250. But with any images over those dimensions, to crop/scale them down.

    Thanks again for your time!

    Matt

  • #4 / Nov 30, 2008 9:46am

    Mark Bowen

    12637 posts

    Hi Matt,

    Sorry for not coming back sooner on this one but things have been hectic lately.

    I still think that it might be some parsing issues that you have going on here. I think the best thing to do might be to post to the Image Sizer plugin thread and see if anyone has any ideas over there. You might even contact the author of the plugin as I’m sure he might have some ideas too. If I am right on the parsing problems though then I think you may require some very clever usage of embedded templates to get what you need as if I am reading everything correctly it looks like you almost need a 3-tier stage parsing. I could be wrong on that though.

    Anyway I would probably suggest posting to the Image Sizer plugin thread and seeing if anyone else over there has any ideas possibly.

    Best wishes,

    Mark

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases