Two ways to show images What's the difference

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
(M)
Forum Members
Forum Members
Posts: 118
Joined: Tue Mar 18, 2008 11:43 pm

Two ways to show images What's the difference

Post by (M) »

Can anyone tell me what the difference is between;
{CGSmartImage src=$image->file}
and
{CGSmartImage src=$image->file|escape:'url'|replace:'%2F':'/'}
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Two ways to show images What's the difference

Post 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.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1974
Joined: Mon Jan 29, 2007 4:47 pm

Re: Two ways to show images What's the difference

Post 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.
"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!
(M)
Forum Members
Forum Members
Posts: 118
Joined: Tue Mar 18, 2008 11:43 pm

Re: Two ways to show images What's the difference

Post 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.
Post Reply

Return to “Modules/Add-Ons”