Exemplo n.º 1
0
 * Parameters
 * -----------------------------
 * @param integer &asset_id (required)
 * @param integer &width in pixels (optional)
 * @param integer &height in pixels (optional)
 *
 * Variables
 * ---------
 * @var $modx modX
 * @var $scriptProperties array
 *
 * @package assman
 */
$core_path = $modx->getOption('assman.core_path', null, MODX_CORE_PATH . 'components/assman/');
require_once $core_path . 'vendor/autoload.php';
$Snippet = new \Assman\Snippet($modx);
$Snippet->log('src', $scriptProperties);
$asset_id = (int) $modx->getOption('asset_id', $scriptProperties);
$width = (int) $modx->getOption('width', $scriptProperties);
$height = (int) $modx->getOption('height', $scriptProperties);
// called as output filter?
if (isset($input) && isset($options)) {
    $asset_id = (int) $input;
    if (strpos($options, 'x') !== false) {
        list($width, $height) = explode('x', $options);
    }
}
$Asset = $modx->getObject('Asset', $asset_id);
if (!$Asset) {
    $modx->log(\modX::LOG_LEVEL_DEBUG, "No results found", '', 'src', __LINE__);
    return;
Exemplo n.º 2
0
 * Variables
 * ---------
 * @var $modx modX
 * @var $scriptProperties array
 *
 * Usage
 * ------------------------------------------------------------
 * To get all Images on certain page
 * [[!getPageAssets? &page_id=`[[*id]]` &outerTpl=`sometpl` &innerTpl=`othertpl` &firstCLass=`first` &is_active=`1` &limit=`0`]]
 * [[!getPageAssets? &page_id=`[[*id]]` &outerTpl=`sometpl` &innerTpl=`othertpl` &is_active=`1` &limit=`1`]]
 *
 * @package assman
 */
$core_path = $modx->getOption('assman.core_path', null, MODX_CORE_PATH . 'components/assman/');
require_once $core_path . 'vendor/autoload.php';
$Snippet = new \Assman\Snippet($modx);
$Snippet->log('getProductImages', $scriptProperties);
// Formatting Arguments:
$innerTpl = $modx->getOption('innerTpl', $scriptProperties, '<li><img src="[[+Asset.url]]" width="[[+Asset.width]]" height="[[+Asset.height]]" alt="[[+Asset.alt]]" /></li>');
$outerTpl = $modx->getOption('outerTpl', $scriptProperties, '<ul>[[+content]]</ul>');
$firstTpl = $modx->getOption('firstTpl', $scriptProperties, $innerTpl);
$lastTpl = $modx->getOption('lastTpl', $scriptProperties, $innerTpl);
$onOne = $modx->getOption('onOne', $scriptProperties, 'innerTpl');
$sort = $modx->getOption('sort', $scriptProperties, 'PageAsset.seq');
$dir = $modx->getOption('dir', $scriptProperties);
// Default Arguments:
$scriptProperties['is_active'] = (bool) $modx->getOption('is_active', $scriptProperties, 1);
$scriptProperties['limit'] = (int) $modx->getOption('limit', $scriptProperties, null);
$page_id = (int) $modx->getOption('page_id', $scriptProperties);
// Just being safe in case this is run without a resource in context
if (!$page_id) {
Exemplo n.º 3
0
 * -----------------------------
 * @param integer &asset_id 
 * @param integer &width in pixels
 * @param integer &height in pixels
 * @param string &tpl either a MODX chunk or a formatting string
 *
 * Variables
 * ---------
 * @var $modx modX
 * @var $scriptProperties array
 *
 * @package assman
 */
$core_path = $modx->getOption('assman.core_path', null, MODX_CORE_PATH . 'components/assman/');
require_once $core_path . 'vendor/autoload.php';
$Snippet = new \Assman\Snippet($modx);
$Snippet->log('Asset', $scriptProperties);
$asset_id = (int) $modx->getOption('asset_id', $scriptProperties);
$width = (int) $modx->getOption('width', $scriptProperties);
$height = (int) $modx->getOption('height', $scriptProperties);
$tpl = $modx->getOption('tpl', $scriptProperties, '<img src="[[+url]]" width="[[+width]]" height="[[+height]]" alt="[[+alt]]" />');
$Asset = $modx->getObject('Asset', $asset_id);
if (!$Asset) {
    $modx->log(\modX::LOG_LEVEL_DEBUG, "No results found", '', 'Asset', __LINE__);
    return;
}
$ass_props = array('asset_id' => $Asset->get('asset_id'), 'title' => $Asset->get('title'), 'alt' => $Asset->get('alt'), 'width' => $Asset->get('width'), 'height' => $Asset->get('height'), 'thumbnail_url' => $Asset->get('thumbnail_url'), 'url' => $Asset->get('url'));
if ($Asset->is_image) {
    if ($width == 0 && $height > 0) {
        // Calculate the new dimensions
        $nx = floor($height * ($Asset->get('width') / $Asset->get('height')));