Hi all,
I have been happily using the excellent {exp:imgsizer plugin to resize images from the main photo gallery into other templates, and has worked well.
I have a very strange problem now, which I am hoping someone could help me with.
I have a weblog called ‘News’, and within this I have a field that contains a URL to an image. If I edit the weblog entry, and cut and paste the URL into a browser, it works.
In my template, if I output the contents of the field (news_image), I indeed get the fully qualified URL displayed, and again, if I cut and paste this into a browser, it works.
So, my field has a value such as : news_image = “http://www.myserver.com/mygallery/data/imagename.gif”
In my template I am doing the following:-
{exp:imgsizer:size src="{news_image}" width="150" alt="My Image"}I would expect imgsizer to take this and covert to:-
<a href="http://www.myserver.com/mygallery/data/imagename.gif" width="150" alt="My Image">But, for some reason, it returns nothing, which suggests that it was unable to find the image.
If I code the tag like this:-
{exp:imgsizer:size src="http://www.myserver.com/mygallery/data/imagename.gif" width="150" alt="My Image"}It works.
So I am really confused, why would it work with a hard coded path, and not work with a variable being passed from a weblog.
HELP!!!!!!
Cheers, Mark.
Update!
I now realised that when I defined the custom field for my blog to hold the URL value, I set it to be XHTML! Well, when this is parsed back from the weblog, it is pre and post fixed with tags.
I then set the field to plain text, and all is now well.
Please close this thread.
Cheers, Mark.
Hey Mark,
What version of ImgSizer are you using? I’m trying to do the EXACT same thing, and I’m having a similar problem. I checked my custom field and the text formatting is set to “none.”
Here is my code
{exp:weblog:entries weblog="galleries" orderby="random" sort="desc" limit="6"}
<a href="http://{title_permalink=">{exp:imgsizer:size src="{large}" width="290" height="274" alt="Sporting Event Photography" class="entry_img"}</a>
{/exp:weblog:entries}Any ideas? Perhaps a version issue? I’m using version 2.1 as I seem to be having an issue with the latest version of ImgSizer. Maybe that’s the issue?
GG
Hi there,
The specific problem I was encountering was that EE was passing back a fully qualified anchor tag for my image. I was expecting it to return just the filename, but it instead gave me something like:-
<a href="http://www.mysite.com/ee/images/myimage.jpg">http://www.mysite.com/ee/images/myimage.jpg</a>When this is passed to imgsizer, it obviously could not understand this at all.
The solution was a lot simpler than I thought, if you go to CP > Admin > Weblog Administration > Custom Fields and find the custom field that is storing your URL. Then look at it’s properties, and specifically if it is set to be XHTML formatted. Set this to NONE.
This will change the behaviour of this field, and it will return only the string that is defined in the weblog.
So, if you have something like:
{filedir}Myimage.jpgIf should just return the path and filename:-
/ee/images/myimage.jpg
This you can then pass to imgsizer and all should be well.
Hope this helps,
Mark.
Is it that your missing a closing } from the Permalink line?
Try and output the value of your custom field straigh to the browser, by putting it into your template, and see what value you have.
I was also having a problem where the filename and path were being sent with opening and closing
tags.
I am using the latest version, which I think is 2.1
Once you know what is being sent to the browser, you’ll have a better idea why the plugin does not seem to want to work.
Cheers, Mark.
Hey Mark,
Regarding the missing bracket: Actually, when I paste the code into the forums, it’s rewriting it. Bracket isn’t missing in the actual code. Not sure but looks like an EE forums problem.
I have the custom field set to “none.” Still nothing…
By the way, here is what I have in the custom field:
http://www.ginoguarnere.com/images/uploads/sample800px.jpgDoes that provide any clue?
Ok next thing to try, is cut the URL out of your page source (i.e. do a View Page Source) and copy the http link and paste it into a browser.
Does the request to your server return the image requested?
If not, then there is path issue here, and you’ll need to check what your image upload folder is set to, and what permissions are.
If the image retrieves ok, the next thing I would do, is to hardcode the URL into the code:-
{exp:imgsizer:size src="http://www.myserver.com/images/myimage.jpg" height="150" width="188"}If this works, then it indicates that there is something “extra” being passed from EE’s custom field.
Again, do a View Source from the output of your page, and make sure your not getting anything before or after your custom field. View Source will tell you this, since if it’s encasing your custom field with paragraph tags (like mine did), you cannot see this from just looking at the webpage output.
So, in summary:-
1) Check the URL your passing actually working in a browser directly. 2) Hardcode the URL into your plugin code, and see if it works. 3) Always use view source to check the output.
BTW - I am using ImgSizer 2.5.6 which I found a link to at:- http://www.lumis.com/site/page/imgsizer/
Hope this helps,
Mark.
Hi Mark,
So on another template, I’m using this:
<a href="http://www.ginoguarnere.com/expression/index.php/black/gallerythumbs/category/abstract/">{exp:imgsizer:size src="http://www.ginoguarnere.com/images/uploads/IMG_0065.jpg" width="290" height="274" alt="Gino Guarnere Abstract Photography" class="entry_img"}</a>That is working, so a direct link to the photo actually works…test 2 complete, I suppose.
Test 1: URL from source code (the URL that points to the page that calls the image) works correctly…
http://www.ginoguarnere.com/expression/index.php/black/galleryfull/more_testsssss/#c4Source is generating this:
<a href="http://www.ginoguarnere.com/expression/index.php/black/galleryfull/more_testsssss/#c4"></a>The area containing the src to the image itself (between the hrefs) is blank as you can see.
This page, by the way, is an example of all hard-coded image resizes…
And, for what it’s worth, version 2.5.6 just blanks out my pages altogether…it’s not working on my server for some reason or incompatible with something else I’m running…
Ok, if I am reading this right, the url that is being passed to the plugin is a page that calls the image, not a direct link to the image? Is that what you mean?
If this is the case, this will not work to my knowledge, since the ImgSizer plugin requires you to pass to it, a simple URI, and as such, if passed a URI to a page (that goes off to get an image first) it will not be able to manage this.
More over, do you not have a custom field that just contains the path and image name only? I presume that must be in the page that you mention below. Cannot you directly use this code in the template your trying to use ImgSizer in?
So, If I am right, your expecting:-
Page 1 - Contains a reference to {exp:imgsizer} and your passing to this a URI for:- Page 2 - Which contains code to go off and retrieve an image from somewhere and output that image
Since this in effect would pass an object within the browser DOM it will not pass the required path and filename!
I think you’ll have to rethink the structure your using here.
My site I have a single page, that retrieves weblog entries, and the custom field contains only the path and filename, nothing else.
Hope this helps,
Mark.
Test 1: URL from source code (the URL that points to the page that calls the image) works correctly…Source is generating this:http://www.ginoguarnere.com/expression/index.php/black/galleryfull/more_testsssss/#c4The area containing the src to the image itself (between the hrefs) is blank as you can see.<a href="http://www.ginoguarnere.com/expression/index.php/black/galleryfull/more_testsssss/#c4"></a>
Ok!
So, this is the template
<a href="http://{title_permalink=">{exp:imgsizer:size src="{large}" width="290" height="274" alt="Gino Guarnere Sporting Event Photography" class="entry_img"}</a>This in the custom field:
https://ellislab.com/asset/images/team-photo/IMG_2040.JPG" width="2592" height="1944"And that generates a photo on my main page…success!
It was what I had in the custom field itself. I had to add more to the template and put less in the custom field.
OUTSTANDING and THANK YOU 😊
Great news!
You should not have to store the width and height properties in the custom field per se, since you can always use these properties with the ImgSizer plugin directly.
I just pass the URL and Filename to the plugin, and if I need it to resize the image, I specify my height and/or width in the call to the plugin, such as:-
{exp:imgsizer src="{custom_field1}" height="200" width="150"}You’ll find it a whole bunch more flexible to store just the URL and Filename, as you can use these universally across your templates, and just provide those properties for height and width where you need to.
Glad you got it working!
Good luck,
Mark.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.