Page 1 of 1
Two ways to show images What's the difference
Posted: Tue Jun 23, 2015 9:42 am
by (M)
Can anyone tell me what the difference is between;
{CGSmartImage src=$image->file}
and
{CGSmartImage src=$image->file|escape:'url'|replace:'%2F':'/'}
Re: Two ways to show images What's the difference
Posted: Tue Jun 23, 2015 11:22 am
by velden
The resulting output should be no different.
Code: Select all
$image->file|escape:'url'|replace:'%2F':'/'
It will take the value from $image->file
escape it to a string suitable to be used in an url
and then, in that string, replace every possible occurence of '%2F' with '/'.
The resulting string is sent to CGSmartImage as the value for the src parameter.
Why it is done this way? I don't know.
Re: Two ways to show images What's the difference
Posted: Tue Jun 23, 2015 1:07 pm
by Jo Morg
velden wrote:Why it is done this way? I don't know.
I would venture saying that, as CGSmartImage has support for external images, escaping will make sure that the source is a valid URL (be it internal or external) while the alternative will only search for files in the current CMSMS filesystem... check the help for
src parameter of CGSmartImage for specifics.
Re: Two ways to show images What's the difference
Posted: Tue Jun 30, 2015 8:20 am
by (M)
Thank you for the explanation.
My users often use spaces in file names. I notice that it's not allowed in the 'replace' version.