Last active
July 18, 2016 11:25
-
-
Save nilsmunch/e09298d2c1fa1a624c8e52bed540caab to your computer and use it in GitHub Desktop.
Changes to the like.st to accomodate the new image server.
This file contains hidden or 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
/var/www/app/Horsebook/Core/Nodes/Assets/Facades/Assets.php | |
<?php namespace Horsebook\Core\Nodes\Assets\Facades; | |
use Illuminate\Support\Facades\Facade; | |
/** | |
* Class Nodes Facade | |
* | |
* @package Nodes\Support\Facades | |
*/ | |
class Assets extends Facade | |
{ | |
/** | |
* Add file to assets | |
* | |
* @author Morten Rugaard <[email protected]> | |
* | |
* @static | |
* @access public | |
* @param string $file | |
* @param array $settings | |
* @return string | |
*/ | |
public static function add($file, $settings = []) | |
{ | |
return static::$app['nodes.assets']->add($file, $settings); | |
} | |
/** | |
* Get URL of asset file | |
* | |
* @author Morten Rugaard <[email protected]> | |
* | |
* @static | |
* @access public | |
* @param string $file | |
* @param array $settings | |
* @return string | |
*/ | |
public static function url($file, $settings = []) | |
{ | |
return static::$app['nodes.assets']->url($file, $settings); | |
} | |
/** | |
* Alias for easier image resizing | |
* | |
* @author Morten Rugaard <[email protected]> | |
* | |
* @static | |
* @access public | |
* @param string $file | |
* @param mixed $size | |
* @param string $resizing | |
* @param integer $treshold | |
* @return string | |
*/ | |
public static function image($file, $size = [], $resizing = null, $treshold = null) | |
{ | |
// Container | |
$settings = []; | |
if ( ! empty($size)) { | |
$settings['size'] = ( ! is_array($size)) ? '?h='.$size.'&w='.$size : '?h='.$size[1].'&w='.$size[0]; | |
//$settings['size'] = ( ! is_array($size)) ? $size . 'x' . $size : implode('x', $size); | |
} | |
return 'http://images.animalbook.io/images/original/'.$file.$settings['size']; | |
// Image size | |
// Add resizing to settings container | |
if ( ! empty($resizing)) { | |
$settings['resizing'] = $resizing; | |
} | |
// Add treshold to settings container | |
if ( ! empty($treshold)) { | |
$settings['treshold'] = $treshold; | |
} | |
return static::$app['nodes.assets']->url($file, $settings); | |
} | |
/** | |
* Force download URL of asset | |
* | |
* @author Morten Rugaard <[email protected]> | |
* | |
* @static | |
* @access public | |
* @param string $file | |
* @return string | |
*/ | |
public static function download($file) | |
{ | |
return static::$app['nodes.assets']->url($file, [ | |
'forceDownload' => true | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment