Skip to content

Instantly share code, notes, and snippets.

@nilsmunch
Last active July 18, 2016 11:25
Show Gist options
  • Save nilsmunch/e09298d2c1fa1a624c8e52bed540caab to your computer and use it in GitHub Desktop.
Save nilsmunch/e09298d2c1fa1a624c8e52bed540caab to your computer and use it in GitHub Desktop.
Changes to the like.st to accomodate the new image server.
/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 <moru@nodes.dk>
*
* @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 <moru@nodes.dk>
*
* @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 <moru@nodes.dk>
*
* @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 <moru@nodes.dk>
*
* @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