Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
{
"name": "anahkiasen/illuminage",
"description": "Wrapper for the Imagine library to hook into the Laravel framework",
"license": "MIT",
"keywords": [
"laravel",
"imagine",
"thumb",
"images"
],
"authors": [
{
"name": "Maxime Fabre",
"email": "ehtnam6@gmail.com"
}
],
"require": {
"php": ">=5.3.0",
"anahkiasen/html-object": "dev-master",
"illuminate/cache": "~4",
"illuminate/container": "~4",
"illuminate/config": "~4",
"illuminate/routing": "~4",
"illuminate/support": "~4",
"imagine/Imagine": "dev-develop"
},
"require-dev": {
"mockery/mockery": "dev-master"
},
"autoload": {
"psr-0": {
"Illuminage": "src/"
}
},
"minimum-stability": "dev"
"name" : "anahkiasen/illuminage",
"description" : "Wrapper for the Imagine library to hook into the Laravel framework",
"license" : "MIT",
"keywords" : [
"laravel",
"imagine",
"thumb",
"images"
],
"authors" : [
{
"name" : "Maxime Fabre",
"email": "ehtnam6@gmail.com"
}
],
"require" : {
"php" : ">=5.3.0",
"anahkiasen/html-object": "~1.4.0",
"illuminate/cache" : "~4.1",
"illuminate/container" : "~4.1",
"illuminate/config" : "~4.1",
"illuminate/routing" : "~4.1",
"illuminate/support" : "~4.1",
"imagine/imagine" : "~0.5.0"
},
"require-dev" : {
"mockery/mockery": "dev-master"
},
"autoload" : {
"psr-0": {
"Illuminage": "src/"
}
},
"minimum-stability": "dev"
}
47 changes: 42 additions & 5 deletions src/Illuminage/Cache.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace Illuminage;

use Illuminate\Support\Facades\File;
/**
* Handles caching and fetching of images
*/
Expand Down Expand Up @@ -54,12 +55,48 @@ public function getHashOf(Image $image)
*
* @return string
*/
public function getCachePathOf(Image $image)
{
return $this->illuminage->getCacheFolder().$this->getHashOf($image);
}
public function getCachePathOf(Image $image)
{
$hash = $this->getHashOf($image);
$cacheFolder = $this->illuminage->getCacheFolder();
$hashedFolder = $cacheFolder . $this->getHashedPath($hash);

/**
if ( $hashedFolder and ! File::isDirectory($hashedFolder) ) @File::makeDirectory($hashedFolder,511,true);



return $hashedFolder . $hash;
}

/**
* get hashed path with subfolders in case random_folder = true
*
* @param $hash
* @return string
*/
public function getHashedPathOf(Image $image){

$hash = $this->getHashOf($image);

return $this->getHashedPath($hash) . $hash;
}

/**
* get hashed folder with subfolders in case random_folder = true
*
* @param $hash
* @return string
*/
public function getHashedPath($hash){

if ($this->illuminage->getOption('random_folder')) {
return substr($hash, 0, 2) . '/' . substr($hash, 2, 2). '/';
}

return '';
}

/**
* Check if an image is in cache
*
* @param Image $image
Expand Down
Loading