gdm
gdm

Reputation: 7978

Cakephp strange image src link

I have a backend and a frontend. In the frontend all is right. The image link is correct and the image is displayed.

/img/imgProducts/Coda_VolpeAmineo%20Coda%20di%20Volpe%20IGP%206%20bottiglie%20?1367589931

In the backend, same code, I have a blank image.

/img/imgProducts/Coda_VolpeAmineo%20Coda%20di%20Volpe%20IGP%206%20bottiglie%20

Why in the frontend I see that random number? Without that the image is blank. Who is putting that number?

The code is

 echo ($html->image(($this->data['Product']['imagelink']),array('title'=>$this->data['Product']['name'],'width'=>80 )));

Upvotes: 0

Views: 149

Answers (2)

thaJeztah
thaJeztah

Reputation: 29137

Asset timestamping

The random number at the end of the URL is a timestamp, used to prevent caching older versions of the image by webbrowsers.

By default, timestamping assets (images) is disabled, but it may be enabled during development (I.e. when 'debug' is enabled), but can also be forced by setting the Asset.timestamp configuration inside app/Config/core.php to 'force'

Look for Configure::write('Asset.timestamp', true); in your app. See this line inside the core.php configuration file:

https://github.com/cakephp/cakephp/blob/master/app/Config/core.php#L212

important

If you're seeing timestamps in your URLs, this may be caused by debug being enabled inside app/Config/core.php. Running a live website with debug enabled is really discouraged. Not only will this make your website slow (as server-side caching is disabled), it will also output error-messages inside the browser, which may be a security risk in some cases!

Upvotes: 2

Teej
Teej

Reputation: 12891

That's a URL encoded image link.. You probably have spaces and other characters in the filename of your image.

Upvotes: 2

Related Questions