Skip to content
Snippets Groups Projects
Commit 895f79c4 authored by Ere Maijala's avatar Ere Maijala Committed by Demian Katz
Browse files

Add timestamps to image links. (#1277)

Add timestamps to static image urls like is already done for js and css files so that images can be cached without risk of missing any updates.
parent a3416bf9
No related merge requests found
...@@ -199,7 +199,7 @@ class ThemeInfo ...@@ -199,7 +199,7 @@ class ThemeInfo
* if boolean false, return containing theme name; if self::RETURN_ALL_DETAILS, * if boolean false, return containing theme name; if self::RETURN_ALL_DETAILS,
* return an array containing both values (keyed with 'path' and 'theme'). * return an array containing both values (keyed with 'path' and 'theme').
* *
* @return string * @return string|array|null
*/ */
public function findContainingTheme($relativePath, $returnType = false) public function findContainingTheme($relativePath, $returnType = false)
{ {
......
...@@ -66,13 +66,19 @@ class ImageLink extends \Zend\View\Helper\AbstractHelper ...@@ -66,13 +66,19 @@ class ImageLink extends \Zend\View\Helper\AbstractHelper
{ {
// Normalize href to account for themes: // Normalize href to account for themes:
$relPath = 'images/' . $image; $relPath = 'images/' . $image;
$currentTheme = $this->themeInfo->findContainingTheme($relPath); $details = $this->themeInfo->findContainingTheme(
$relPath, \VuFindTheme\ThemeInfo::RETURN_ALL_DETAILS
);
if (null === $currentTheme) { if (null === $details) {
return null; return null;
} }
$urlHelper = $this->getView()->plugin('url'); $urlHelper = $this->getView()->plugin('url');
return $urlHelper('home') . "themes/$currentTheme/" . $relPath; $url = $urlHelper('home') . "themes/{$details['theme']}/" . $relPath;
$url .= strstr($url, '?') ? '&_=' : '?_=';
$url .= filemtime($details['path']);
return $url;
} }
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment