We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

plugin: Image Sizer

Development and Programming

Boxhead's avatar
Boxhead
13 posts
16 years ago
Boxhead's avatar Boxhead

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() [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);

any help would be very much appreciated

       
elemental's avatar
elemental
77 posts
16 years ago
elemental's avatar elemental

Just a heads up when using Image Sizer with MSM with different domains.

Make sure you create the cache folder and give it 777 writing right before using it for the first time. I spent a whole lot a time figuring it out then one of the comments mentioned something similar.

Mind you the primary site where the system folder is hosted was fine only the subsequent sites with different root folders than the primary site created the cache folder with corresponding 777 rights but thumbnails were not written.

       
molotovfx's avatar
molotovfx
25 posts
16 years ago
molotovfx's avatar molotovfx

Lumis,

Just wanted to post my thanks for such a great plugin, it has so many uses. So thanks for a top notch plugin!

Gavin

       
atelier2's avatar
atelier2
181 posts
16 years ago
atelier2's avatar atelier2

Hi

I’ve been using the previous version without any problem. After updating to the latest version, the auto-resize parameters seem confused. I have set my images to crop to 150 width, previously the height followed automatically. Not anymore. Is this a known issue? (I downgraded to the previous version, now all is back to normal again)

(Marvellous plug-in, btw…! thanks a lot!)

       
dreedenator's avatar
dreedenator
40 posts
16 years ago
dreedenator's avatar dreedenator

Hi there,

awesome plugin! I’ve had great success with it developing on my local server and now that it’s live it won’t work.

It works when I remove the plugin. The thread that led to the discovery that it’s the filter causing it is here: http://ellislab.com/forums/viewthread/99392/#502210

my path and url of my main upload directory is: /home/lamdeni1/public_html/images/uploads/ http://server1.alefhost.com/~lamdeni1/images/uploads/

This is how I’m calling it in my template:

<li><a href="#"><em></em>{exp:imgsizer:size {carousel_photo_1} height="282" width="390" alt="{title}" debug="1"} </li>

I’ve tried debug=”1” to see which error I receive and it is:

src = /~lamdeni1/images/uploads/cache/20080916_3390-390x282.JPG img_base = /~lamdeni1/images/uploads/cache img_basename = 20080916_3390-390x282.JPG img_extension = JPG img_filename = 20080916_3390-390x282 img_rootstep = /usr/local/apache/htdocs//~lamdeni1/images/uploads/cache img_rootpath = img_fromroot = /20080916_3390-390x282.JPG /20080916_3390-390x282.JPG is not readable

you can see my site at: http://server1.alefhost.com/~lamdeni1/index.php

on the carousel on the top home page the first image is set to debug, the second is as normal and the third state (“pilot trips”) is the image as it appears when I take the filter off.

HOPE to get to the bottom of this ! Thanks!

       
dreedenator's avatar
dreedenator
40 posts
16 years ago
dreedenator's avatar dreedenator

I STILL HAVE THE ISSUE, WHERE IT WORKS GREAT LOCAL BUT NOT LIVE.

I tried this thing: http://ellislab.com/forums/viewthread/62138/P234/#431893

that was pretty complicated for me!

I persevered and got it to work to change the path but it still doesn’t show..so I don’t know about my path. in the example forum post I sent you that persons path had www and public_html in it…In mine, I assume it’s different…since that person based their path on the output that was produced by running the debug, I only assume I should use what my debug returned as well.

so when I typed debug=”1” into the plugin call in my template file and it returned

src = /~lamdeni1/images/uploads/cache/20080916_3390-390x282.JPG img_base = /~lamdeni1/images/uploads/cache img_basename = 20080916_3390-390x282.JPG img_extension = JPG img_filename = 20080916_3390-390x282 img_rootstep = /usr/local/apache/htdocs//~lamdeni1/images/uploads/cache img_rootpath = img_fromroot = /20080916_3390-390x282.JPG /20080916_3390-390x282.JPG is not readable

so I did all that crazy complicated stuff in the linked post I gave you, here it is again: http://ellislab.com/forums/viewthread/62138/P234/#431893

and managed to get the output looking like this:

src = /~lamdeni1/images/uploads/cache/20080916_3390-390x282.JPG
          img_base = /~lamdeni1/images/uploads/cache
          img_basename = 20080916_3390-390x282.JPG
          img_extension = JPG
          img_filename = 20080916_3390-390x282
          img_rootstep = /usr/local/apache/htdocs/images/uploads/cache
          img_rootpath = 
          img_fromroot = /20080916_3390-390x282.JPG
                  

      /20080916_3390-390x282.JPG is not readable

I’ve since tried re-inlcluding the /lamdeni/ back in..by changing the number in the plugin php code from 11 to 1…still didn’t work…the debug returned from that was:

src = /~lamdeni1/images/uploads/cache/20080916_3390-390x282.JPG
          img_base = /~lamdeni1/images/uploads/cache
          img_basename = 20080916_3390-390x282.JPG
          img_extension = JPG
          img_filename = 20080916_3390-390x282
          img_rootstep = /usr/local/apache/htdocs/lamdeni1/~lamdeni1/images/uploads/cache
          img_rootpath = 
          img_fromroot = /20080916_3390-390x282.JPG
                  

      /20080916_3390-390x282.JPG is not readable

my path.php looks like this:

<?php


// ------------------------------------------------------
// MANUALLY CONFIGURABLE VARIABLES
// See user guide for more information
// ------------------------------------------------------

$template_group = "";
$template = "";
$site_url = "";
$site_index = "";
$site_404 = "";
$global_vars = array(); // This array must be associative


$global_vars =
array(
$_SERVER['DOCUMENT_ROOT'] = '/usr/local/apache/htdocs/lamdeni1'
); 

?>

here is the section of the plugin.php code I altered..mine are flushed left

/** -------------------------------------
        /* get the images real path on the server 
        /* some additions Thanks to Gonzalingui
        /** -------------------------------------*/

            $img = pathinfo($src);
                        
            $img_base = ( ! isset($img['dirname'])) ? '' : $img['dirname'];
            
$img_base_edit = substr($img_base, 1);
            
            $img_basename = ( ! isset($img['basename'])) ? '' : $img['basename'];
            $img_extension = ( ! isset($img['extension'])) ? '' : $img['extension'];
            $img_filename = str_replace('.'.$img_extension, '', $img_basename);
            $img_filename = $FNS->filename_security($img_filename);
            
            $img_rootstep = (isset($_SERVER['DOCUMENT_ROOT'])) ? $_SERVER['DOCUMENT_ROOT'] : @getenv('DOCUMENT_ROOT');

$img_rootstep = $img_rootstep.'/'.$img_base_edit; 
    
            // checks the path and removes // if the src path was entered as relitive 
            $img_rootpath = realpath($img_rootstep);
            $img_rootpath = $FNS->remove_double_slashes($img_rootpath);
                
            $img_fromroot = $img_rootpath."/".$img_filename.".".$img_extension;
            $img_fromroot = $FNS->remove_double_slashes($img_fromroot);
            
            $ourbug = "
            <pre>
    src = {$src}
    img_base = {$img_base}
    img_basename = {$img_basename}
    img_extension = {$img_extension}
    img_filename = {$img_filename}
    img_rootstep = {$img_rootstep}
    img_rootpath = {$img_rootpath}
    img_fromroot = {$img_fromroot}
            </pre>

<pre><code>        ";</code></pre>

I FEEL SOOOO CLOSE…

I definitely think the above solution is the answer. I just need to know my path now!

If this is the relative path: /home/lamdeni1/public_html/images/uploads/

then what is my full path? The debug returns: /usr/local/apache/htdocs/

So I GUESS THAT that is it? but seems fishy!!

The other person that fixed their same problem had a different path returned in their debug…which confuses me, theirs was :/usr/www/gm/public_html

How come mine is local and not www? and in my ftp program I do indeed need to enter into a public_html file..so how come my path doesn’t have public_html in it?

some more misc. details:

my site url is: http://server1.alefhost.com/~lamdeni1/

service path to upload directory: /home/lamdeni1/public_html/images/uploads/

url of upload directory: http://server1.alefhost.com/~lamdeni1/images/uploads/

       
dreedenator's avatar
dreedenator
40 posts
16 years ago
dreedenator's avatar dreedenator

FINALLY PROBLEM SOLVED!

how I did it step by step:

STEP 1 put this code in a php page just by itself called test.php and place it in your images/uploads/cache folder:

<?php echo dirname ($_SERVER[SCRIPT_FILENAME]) . '/'; ?>

STEP 2 run the debug by placing debug=”1” inside your template where the plugin is used.. In my case it was like this:

<li><a href="#"><em></em>{exp:imgsizer:size {carousel_photo_1} height="282" width="390" alt="{title}" debug="1"}</li>

STEP 3 Then I browsed to the test.php and found the path was: /home/lamdeni1/public_html/images/uploads/cache/

STEP 4 I opened up my path.php file and inserted it like so:

<?php

// ------------------------------------------------------
// DO NOT ALTER THIS FILE UNLESS YOU HAVE A REASON TO

// ------------------------------------------------------
// Path to the directory containing your backend files

$system_path = "./system/";

// ------------------------------------------------------
// MANUALLY CONFIGURABLE VARIABLES
// See user guide for more information
// ------------------------------------------------------

$template_group = "";
$template = "";
$site_url = "";
$site_index = "";
$site_404 = "";
$global_vars = array(); // This array must be associative


$global_vars =
array(
$_SERVER['DOCUMENT_ROOT'] = '/home/lamdeni1/public_html/'
); 

?>

then I looked what the debug returned in img_rootstep:

img_rootstep = /home/lamdeni1/public_html//~lamdeni1/images/uploads/cache

STEP 5 those that extra slash and ~lamdeni1 are the only thing holding me back now! count how many characters are holding you back from having the correct path. mine is 11. remember that magic number!

looked for the section in the pi.imgsizer.php, my additions are flushed left. Just copy this whole section from my code and exactly paste it over the same section in the plugin file if you are following my guide. and place your magic number where my 11 is.

/** -------------------------------------
        /* get the images real path on the server 
        /* some additions Thanks to Gonzalingui
        /** -------------------------------------*/

            $img = pathinfo($src);
                        
            $img_base = ( ! isset($img['dirname'])) ? '' : $img['dirname'];
            
$img_base_edit = substr($img_base, 11);
            
            $img_basename = ( ! isset($img['basename'])) ? '' : $img['basename'];
            $img_extension = ( ! isset($img['extension'])) ? '' : $img['extension'];
            $img_filename = str_replace('.'.$img_extension, '', $img_basename);
            $img_filename = $FNS->filename_security($img_filename);
            
            $img_rootstep = (isset($_SERVER['DOCUMENT_ROOT'])) ? $_SERVER['DOCUMENT_ROOT'] : @getenv('DOCUMENT_ROOT');

$img_rootstep = $img_rootstep.'/'.$img_base_edit; 
    
            // checks the path and removes // if the src path was entered as relitive 
            $img_rootpath = realpath($img_rootstep);
            $img_rootpath = $FNS->remove_double_slashes($img_rootpath);
                
            $img_fromroot = $img_rootpath."/".$img_filename.".".$img_extension;
            $img_fromroot = $FNS->remove_double_slashes($img_fromroot);
            
            $ourbug = "
            <pre>
    src = {$src}
    img_base = {$img_base}
    img_basename = {$img_basename}
    img_extension = {$img_extension}
    img_filename = {$img_filename}
    img_rootstep = {$img_rootstep}
    img_rootpath = {$img_rootpath}
    img_fromroot = {$img_fromroot}
            </pre>

<pre><code>        ";</code></pre>

THAT’S HOW I FINALLY GOT MY IMAGES WORKING! HOPE THIS HELPS SOMEONE!

       
dreedenator's avatar
dreedenator
40 posts
16 years ago
dreedenator's avatar dreedenator

UH OH TROUBLE IN PARADISE

Well I thought I successfully solved all my image woes. However I noticed for now rhyme or reason some pages decide to call the image with a different path!

these two pages are identical and built from the same exact weblog:

the page without images

the page with images

the working one pulls the image like this: /~lamdeni1/images/uploads/cache/

the non-working one still thinks it’s on my local machine! : /eelamdeni/images/uploads/cache/

Now I really don’t know how to solve this!

       
evasion's avatar
evasion
58 posts
16 years ago
evasion's avatar evasion

Try to delete cache from your FTP (ie: generated thumbnails), and it should do the trick !

       
dreedenator's avatar
dreedenator
40 posts
16 years ago
dreedenator's avatar dreedenator

thanks! tried it but it didn’t work :( Any other ideas???

       
Deron Sizemore's avatar
Deron Sizemore
1,033 posts
16 years ago
Deron Sizemore's avatar Deron Sizemore

I’m using ImageSizer to resize an image into three different sizes. One of the sizes is very small (50px x 30px). Is there any way I can make this take the full size image and somehow crop it from the center to make the small image? I noticed that in the docs it explains that if width is equal to height, it crops the image from the center to make a square, but it doesn’t seem to be the case when creating an image where width is not equal to height. The currently functionality just seems to be taking my full size image and simply re-sampling it down to 50x30 and making a smaller version with no cropping.

It seems to crop correctly if I’m placing a relative image path into the src=”” parameter but doesn’t crop correctly if I place an EE custom field tag into the src=”” parameter.

I’m using it like this:

{exp:imgsizer:size src="{gallery_image}" width="50" height="30" alt="{title}"}

and it simply resizes the image down to 50x30.

But if I use this:

{exp:imgsizer:size src="images/test1.gif" width="50" height="30" alt="{title}"}

It seems to work just fine as far as cropping it from the middle. Seems weird.

Thanks

       
dreedenator's avatar
dreedenator
40 posts
16 years ago
dreedenator's avatar dreedenator

Hi Deron,

I haven’t been paying attention too much on if it crops from the center etc.

I’m calling mine like this though:

{exp:imgsizer:size {carousel_photo_1} height="282" width="390" alt="{title}"}

try that format and see if it does what you want it to?

       
Deron Sizemore's avatar
Deron Sizemore
1,033 posts
16 years ago
Deron Sizemore's avatar Deron Sizemore

Nope, didn’t work. I didn’t think it would, but tried anyway just for the heck of it. Unless some of your code didn’t make it through in the post, I’m not sure what you have above is even valid? There’s no “src” tag in the imgsizer tag, so I don’t see how it could work? How are you doing it?

       
dreedenator's avatar
dreedenator
40 posts
16 years ago
dreedenator's avatar dreedenator

Deron,

I have no idea how I arrived to that. I copied it from this tutorial from train-ee.com and I went back to check his example and it DOES have src=”” in there. I have no clue how mine got mangled, but it works! and if I take the src out, IT DOESN’T WORK AT ALL. If I run the debug=”1” in the string it returns “can’t pass html into ___”(I forget the word that was used)

Leaving that aside, I have a real big problem I was wondering if you could help with… I moved from local to live changed all paths and ALMOST all images show (THIS PROBLEM IS WITHOUT USING THE PLUGIN RESIZER)like normal but randomly some images don’t because their paths still point to my local !?!?!?!? my post about it is here. I’d be really grateful if you had any ideas or input. Any support or suggestions will keep me sane.

       
Deron Sizemore's avatar
Deron Sizemore
1,033 posts
16 years ago
Deron Sizemore's avatar Deron Sizemore

Daina,

I’m sorry, I really have no clue as to what’s going on with your problem. Seems like a path problem (like everyone else has said) but exactly what that problem is, I don’t know. I could possibly take a look behind the scenes at your EE Control Panel to get a better idea of what’s going on, but aside from that, I’m pretty lost.

       
First 18 19 20 21 22 Last

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.