<?php
/**
* 47_CustomModule for Contao Open Source CMS
*
* Copyright (C) 2016 Studienkreis Tourismus
* @author Holger Neuner <neuner@47gradnord.de>
* @project 47_CustomModule
* @license commercial
*/
namespace CustomModule\Frontend\Elements;
use Contao\Frontend;
class CustomElements extends Frontend
{
/**
* Generate Src Image
* @param $uuidSrcImage
* @param null $intWidth
* @param null $intHeight
* @param string $strMode
* @param $mode
* @return null|string
*/
public static function generateSrcImage($uuidSrcImage, $intWidth = NULL , $intHeight = NULL, $strMode = 'center_center', $mode = 'FE')
{
// If BE
if ($mode == 'BE')
{
return CustomElements::generateBeSrcImage($uuidSrcImage);
}
// Get File
$objFile = \FilesModel::findByUuid($uuidSrcImage);
// No File exists
if ( $objFile === null )
{
return '';
}
// Handle File
if ( $objFile !== null )
{
if ( $intWidth == '' && $intHeight == '')
{
return $objFile->path;
}
// Return Image Path
return \Image::get($objFile->path, $intWidth, $intHeight, $strMode);
}
}
/**
* Generate BE Src Image
* @param $uuidSrcImage
* @return null|string
*/
public static function generateBeSrcImage($uuidSrcImage)
{
// Get File
$objFile = \FilesModel::findByUuid($uuidSrcImage);
if ( $objFile === null )
{
return '';
}
// Return Image Path
return \Image::get($objFile->path, '300', '', 'proportional');
}
}