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

Trying to use imgsizer

Development and Programming

Marie-Jo Jones's avatar
Marie-Jo Jones
23 posts
16 years ago
Marie-Jo Jones's avatar Marie-Jo Jones

I’m trying to use imgsizer. When I use the hard link, such as

{exp:imgsizer:size src=''http://mysite.com/somefolders/image.jpg''}

, it works. But I’d like to use relative links. I tried:

{exp:imgsizer:size src="{site_url}folders/image.jpg"}

where global variable {site_url} holds

http://mysite.com/somefolders/

I also tried

{exp:imgsizer:size src="{test}" width ="150px"}

where this local variable defined on top of the template holds the full hard link which worked. No result. No success either if this link is held in a field. Tried the relative paths without variables or fields as per documentation. With and without the / since it’s unclear in the doc which path is used. With up to …./or /….. in the hope to find out. Nothing. Would someone have the kindness to give me an example which works. Thanks.

       
Peter Lewis's avatar
Peter Lewis
280 posts
16 years ago
Peter Lewis's avatar Peter Lewis

A couple of things just ensure it’s nothing simple…

I assume these are just typos from your post (and were correct in the template)…

{exp:imgsizer:size src="{site_url}folders/image.jpg"}

should read:

{exp:imgsizer:size src="{site_url}somefolders/image.jpg"}

Or, as {site_url} = “http://mysite.com/somefolders/” surely it should be:

{exp:imgsizer:size src="{site_url}image.jpg"}
{exp:imgsizer:size src="{test}" width ="150px"}

should read:

{exp:imgsizer:size src="{test}" width="150px"}

What does the following render?

{exp:imgsizer:size src="{site_url}somefolders/image.jpg" justurl="yes" width="150px"}
{exp:imgsizer:size src="/somefolders/image.jpg" justurl="yes" width="150px"}
{exp:imgsizer:size src="{site_url}somefolders/image.jpg" width="150px"}
URL={sized}

width={width}
{/exp:imgsizer:size}
       
Marie-Jo Jones's avatar
Marie-Jo Jones
23 posts
16 years ago
Marie-Jo Jones's avatar Marie-Jo Jones

Thanks for your reply, will try your code right now.

       
Marie-Jo Jones's avatar
Marie-Jo Jones
23 posts
16 years ago
Marie-Jo Jones's avatar Marie-Jo Jones

None of the three return anything, I’m afraid.

       
Marie-Jo Jones's avatar
Marie-Jo Jones
23 posts
16 years ago
Marie-Jo Jones's avatar Marie-Jo Jones

Calling a halt since I’ve been at my desk for practically 36 hours in a row. Wish you a good week-end.

       
Peter Lewis's avatar
Peter Lewis
280 posts
16 years ago
Peter Lewis's avatar Peter Lewis

I expect it’s your path, or possibly the path of the generated resized image. Have you created the sized folder as per the instructions on the plugin?

You said this works:

{exp:imgsizer:size src="http://mysite.com/somefolders/image.jpg"}

But does this?

{exp:imgsizer:size src="http://mysite.com/somefolders/image.jpg" width="150px"}

If the latter doesn’t work I’d say its the output folder - make sure its been created on the server and is writeable.

       
Marie-Jo Jones's avatar
Marie-Jo Jones
23 posts
16 years ago
Marie-Jo Jones's avatar Marie-Jo Jones

Yes, width is taken into account when the link is hard-coded. Also thought problem arose from the path. But when I resize the image contained in the field, it doesn’t work either tho’ the link is correct when I output the content. And there’s nothing but the link in this field.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Hiya,

What do you get if you simply output your image field {test}. Don’t use ImageSizer for a while and just see what just the image custom field variable spits out. It may well have tags surrounding it. If it does then the fix will be nice and easy.

If not then what sort of field is this?

Best wishes,

Mark

       
Marie-Jo Jones's avatar
Marie-Jo Jones
23 posts
16 years ago
Marie-Jo Jones's avatar Marie-Jo Jones

It outputs the equivalent to the hard-coded link, i.e . See here (bottom of page, last line before the comment) http://dedwyddjones.com/dsh01/index.php/writing/vol-09/bard

       
Marie-Jo Jones's avatar
Marie-Jo Jones
23 posts
16 years ago
Marie-Jo Jones's avatar Marie-Jo Jones

Just looked at the html code of the page. No hidden rubbish. Clean link.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

So you placed in the tag surrounding all that text yourself?

What type of field are you using to hold the link? Just a standard text field or something else?

One other thing to try is if you said that if you hard-code the whole link then it works, right?

If you use {site_url} then it doesn’t?

I think (If I remember from my usage of the plugin) that it doesn’t work with {site_url} due to parsing order.

       
Peter Lewis's avatar
Peter Lewis
280 posts
16 years ago
Peter Lewis's avatar Peter Lewis

Sorry, bit confused by your reply.

Yes, width is taken into account when the link is hard-coded.

So it works with:

{exp:imgsizer:size src="http://mysite.com/somefolders/image.jpg" width="150px"}
But when I resize the image contained in the field, it doesn’t work either

Or it doesn’t work with:

{exp:imgsizer:size src="http://mysite.com/somefolders/image.jpg" width="150px"}

Can you confirm that the sized folder has been created on your server and has the correct access permissions.

The link entering image sizer maybe correct, but if the output folder for the resized image (that imgsizer creates on the fly) doesn’t exist nothing will be output to your page.

When you said this worked:

{exp:imgsizer:size src="http://mysite.com/somefolders/image.jpg"}

I’m guessing (without testing), but that will output the original image path you entered because it’s not resizing anything (nothing specified for width or height).

I think (If I remember from my usage of the plugin) that it doesn’t work with {site_url} due to parsing order.

Just did a test on this and Mark is right, {site_url} won’t work, but obviously going from you root folder will be fine.

       
Marie-Jo Jones's avatar
Marie-Jo Jones
23 posts
16 years ago
Marie-Jo Jones's avatar Marie-Jo Jones

Thank you both for your reply. The only 2 lines which output something are either:

{exp:imgsizer:size src="/dsh01/images/uploads/pix/dedwyddjones_lp_bard01.jpg" justurl="yes" width="50px"}

or

{exp:imgsizer:size src="/dsh01/{main_image_link}"   justurl="yes" height="50px"  width="50px"}

They both output: /images/sized/dsh01/images/uploads/pix/dedwyddjones_lp_bard01-50pxx50px.jpg.

This makes sense since my EE install is not in the root of the site but in a folder just below it, called /dsh01/. But of course, the folder /dsh01/ gets in the way so the link will not work.

Had assumed I could change the base_path and then get rid of the /dsh01/ folder in the image link. To have something like:

{exp:imgsizer:size src="/{main_image_link}" base_path="/dedwyddjones.com/dsh01/"  justurl="yes" height="50px"  width="50px"}

Tried all kind of variations,i.e. putting base_path before the src, including the folder the website is contained in – that is “/webjonet/dedwyddjones.com/dsh01/”, reducing base_path to “/dsh01/”. No good.

What would you suggest?

       
Marie-Jo Jones's avatar
Marie-Jo Jones
23 posts
16 years ago
Marie-Jo Jones's avatar Marie-Jo Jones

Should have repeated that yes, hard-coded link worked from the start. Such as:

{exp:imgsizer:size src="http://dedwyddjones.com/dsh01/images/uploads/pix/my_image.jpg"   justurl="yes" height="50px"  width="50px"}

But links such as below don’t work, tho’ {main_image_link) has the equivalent to the above, i.e. images/uploads/pix/my_image.jpg.

{exp:imgsizer:size src="http://dedwyddjones.com/dsh01/{main_image_link}"   justurl="yes" height="50px"  width="50px"}

Yes, I have two /sized/ folders, one below /images/ the other below /images/uploads/pix/, both 777.

       
Peter Lewis's avatar
Peter Lewis
280 posts
16 years ago
Peter Lewis's avatar Peter Lewis

If your first one works with the full path and resize, then that means there’s no path problems for the plugin. So the question is your variable.

How are you creating it? {assign_variable:??}, Templates > Global Variables or is it contained in the image field?

As Mark mentioned before, display it and check the html to ensure there’s no extra tags or anything also being chucked out in the variable.

       
1 2

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.