Skip to content

Commit

Permalink
Added cache-busting mechanism
Browse files Browse the repository at this point in the history
Filename of generated image now contains focus point information so
browsers download new image if focus point is changed
  • Loading branch information
jonom committed Sep 15, 2014
1 parent 2600632 commit b7bcef5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions code/FocusPointImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,14 @@ public function PercentageY() {
* @return Image
*/
public function CroppedFocusedImage($width,$height) {
//Cache buster - add coords to filename as percentage (2 decimal points accuracy)
$focusHash = $this->PercentageX() . '-' . $this->PercentageY();
//Only resize if necessary
return $this->owner->isSize($width, $height)
? $this->owner
: $this->owner->getFormattedImage('CroppedFocusedImage', $width, $height);
: $this->owner->getFormattedImage('CroppedFocusedImage', $width, $height, $focusHash);
}

/**
* Generate a resized copy of this image with the given width & height, cropping to maintain aspect ratio and focus point.
* Use in templates with $CroppedFocusedImage
Expand Down

0 comments on commit b7bcef5

Please sign in to comment.