Created
November 13, 2013 19:44
-
-
Save nathanbrauer/7455139 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add to framework/model/Image.php | |
// Ensures all Image URLs have a cachebuster appended so when an image is replaced (same file name), the correct image appears in the browser. | |
public function getURL() { | |
$LastEdited = $this->LastEdited; | |
if (!$LastEdited) { | |
$Original = File::find($this->getFilename()); | |
if (!$Original || !$Original->LastEdited) return parent::getURL(); | |
$LastEdited = $Original->LastEdited; | |
} | |
return parent::getURL().'?'.preg_replace('/[^0-9]+/i','',$LastEdited); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment