JIT images URL encoding issues (escape characters)
This is an open discussion with 9 replies, filed under Extensions.
Search
Ah seems that url escaping the ‘+’ symbol works with normal clean URLs too - not sure why I didn’t try that in the first place!
Escaping Symphony keyword symbols is a good workaround. During our recent Working Group meeting, this has been raised to ensure this is in Symphony’s documentation going forward to increase awareness of this method.
Hi,
Don't know if I'm missing something obvious here, but I've tried escaping the filenames (using Cremol's url-encode template - is there another way?) and still, JIT isn't parsing them.
I've changed <img src="{concat($root, '/image/2/200/150/5/0', images/item/image/@path, '/', images/item/image/filename)}"/>
to
<img>
<xsl:attribute name="src">
<xsl:value-of select="$root"/>
<xsl:text>/image/2/200/150/5/0</xsl:text>
<xsl:value-of select="images/item/image/@path"/>
<xsl:text>/</xsl:text>
<xsl:call-template name="url-encode">
<xsl:with-param name="str" select="images/item/image/filename"/>
</xsl:call-template>
</xsl:attribute>
</img>
and the image url has changed from .../image/2/200/150/5/0/uploads/copy-wrk1-full-rack-nx+pad12.jpg
to .../image/2/200/150/5/0/uploads/copy-wrk1-full-rack-nx%2Bpad12.jpg
but still nothing. When I try to load the escaped url directly, I still get
Error loading image /workspace/uploads/copy-wrk1-full-rack-nx pad12.jpg. Check it exists and is readable.
The plus character is being converted to a space, whether or not I escape it.
Looks like this is a symphony bug...
Filenames containing special characters using JIT gives the above error.
I only tested it with a filename containing a + character.
It display's well referred directly, but through JIT i get the error;
....Check it exists and is readable.
using JIT local or on extern images.
On external images i get:
Unsupported image type. Supported types: GIF, JPEG and PNG
So i guess symphony does not recognize these images as images? Is this a flaw in some build in regular expression?
Edit: Url encoding the '+' with '%2B' does not make a difference...
I guess this would be a JIT issue
My solution to this was to use the messy URL—as suggested by Ben—in combination with Martijn's url-encode utility.
The get parameter 'param' is essentially the same as what follows the image URL parameter in the non-messy URL, so
mysite.com/image/4/400/300/0/uploads/copy-wrk1-full-rack-nx%2Bpad12.jpg
becomes
mysite.com/extensions/jit_image_manipulation/lib/image.php?param=4/400/300/0/uploads/copy-wrk1-full-rack-nx%2Bpad12.jpg
To achieve this in XSLT I used the following code:
<img> <xsl:attribute name="src"> <xsl:value-of select="concat($root, '/extensions/jit_image_manipulation/lib/image.php?param=4/400/300/0', image/@path, '/')"/> <xsl:call-template name="url-encode"> <xsl:with-param name="str" select="image/filename"/> </xsl:call-template> </xsl:attribute> </img>
Success!
I also noticed the problem with the + It seems that the solution is to use the B flag in the JIT Rewrite rule.
Escape non-alphanumeric characters before applying the transformation.
RewriteRule ^image/(.+.(jpg|gif|jpeg|png|bmp))$ extensions/jit_image_manipulation/lib/image.php?param=$1 [B,L,NC]
It works here! :D
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriteflags
It works here! :D
Works here too!,
This should definetly be integrated in the JIT extension
Raise an issue on github?
I already raised this issue, i guess it's case closed now...
Create an account or sign in to comment.
Hi all,
I’m currently trying to call in external images and manipulating them with JIT. Because they’re external I don’t have any control over their naming conventions and unfortunately a few of them seem to be breaking JIT.
An example image is:
When I link to
The ‘+’ symbol in the image filename seems to be breaking JIT.
I found a post on the forum here which mentions using JIT’s messy url which when I url encode the ‘+’ symbol seems to get a result:
This works, but I’m no longer sure how to pass my JIT parameters through defining the crop values. Any ideas anyone?
Many thanks!
Ben