Skip to content

Commit

Permalink
pats self on back for writing snippet blind
Browse files Browse the repository at this point in the history
  • Loading branch information
alanpich committed Oct 21, 2013
1 parent 3d5a842 commit 941981b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
8 changes: 4 additions & 4 deletions core/components/tvimageplus/elements/snippets/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
$image = $imagePlus->getImage($uid);

// Extract render type
$bits = explode(':',str_replace(' ','',strlolower($options)),2);
$type = array_shift($bits);
$bits = explode(':',str_replace(' ','',strtolower($options)),2);
$outputType = array_shift($bits);

// Render output
switch($outputType){

case 'snippet':
if(!count($bits)<1){
if(count($bits)<1){
$modx->log(xPDO::LOG_LEVEL_ERROR,"[Image+] Snippet name not specified");
return '';
}
Expand All @@ -54,7 +54,7 @@
break;

case 'chunk':
if(!count($bits)<1){
if(count($bits)<1){
$modx->log(xPDO::LOG_LEVEL_ERROR,"[Image+] Chunk name not specified");
return '';
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
class ImagePlusImage extends xPDOSimpleObject
{
/** @var \xPDO */
/** @var \modX */
protected $modx;

/** @var ImagePlus\ModxService */
Expand Down Expand Up @@ -122,6 +122,31 @@ public function save($cacheFlag = null)
}


/**
* Parse TV value and return an array of data
* about the TV image
*
* @param bool $ignoreSelf If true, don't add $this to array
* @return array
*/
protected function asParams($ignoreSelf = false)
{
$array = array(
'uid' => $this->get('id'),
'url' => $this->getCacheUrl(),
'width' => $this->get('output_width'),
'height' => $this->get('output_height'),
'mtime' => $this->get('mtime'),
'original' => $this->getOriginalImageUrl(),
);
if(!$ignoreSelf)
$array['image'] = $this;

return $array;
}



/**
* Render output as a URL with an mtime parameter
* for cachebusting
Expand Down Expand Up @@ -165,7 +190,7 @@ public function renderSnippet($snippet)
*/
public function renderChunk($chunk)
{
$params = $this->asParams();
$params = $this->asParams(true);
if(is_numeric($chunk)){
$chunk = $this->modx->getObject('modChunk',$chunk);
if($chunk instanceof modChunk){
Expand Down

0 comments on commit 941981b

Please sign in to comment.