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”
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.
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.”
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:-
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.jpg
If should just return the path and filename:-
/ee/images/myimage.jpg
This you can then pass to imgsizer and all should be well.
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:
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.
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.
mrpiano - 14 October 2009 11:40 AM
Test 1: URL from source code (the URL that points to the page that calls the image) works correctly…
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:-
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.
Thanks, Mark. I did the sizing in the template for my main gallery, thumbs and full image. Now I can minimize the number of custom fields down to ONE and just let Imgsizer make the changes on the fly, like you recommended.