Can anyone tell me what the difference is between;
{CGSmartImage src=$image->file}
and
{CGSmartImage src=$image->file|escape:'url'|replace:'%2F':'/'}
Two ways to show images What's the difference
Re: Two ways to show images What's the difference
The resulting output should be no different.
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.
Code: Select all
$image->file|escape:'url'|replace:'%2F':'/'
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
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.velden wrote:Why it is done this way? I don't know.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Re: Two ways to show images What's the difference
Thank you for the explanation.
My users often use spaces in file names. I notice that it's not allowed in the 'replace' version.
My users often use spaces in file names. I notice that it's not allowed in the 'replace' version.