terminal42 / contao-pageimage

MIT License
12 stars 14 forks source link

Insert tag not working #22

Closed fritzmg closed 9 years ago

fritzmg commented 9 years ago

The insert tag {{pageimage::*}} is not working. The problem is in these lines of code of PageImage.php:

if (null === $arrImage || !isset($arrImages[$strKey])) {
    return '';
}

return $arrImages[$intIndex][$strKey];

$arrImages is not a valid variable in the function's context. Even if you use static::$arrImages instead, there is no variable $intIndex in the function's context. The lines should instead say this:

if (null === $arrImage || !isset($arrImage[$strKey])) {
    return '';
}

return $arrImage[$strKey];

However, then there is another problem. $strKey will default to 'src' when using the insert tag {{pageimage::*}}. But there is no array key named 'src' in $arrImage. The contents in $arrImage come from the \FilesModel. The path to the image is actually in the array key 'path', not 'src'. So line #34 should probably be changed to

$arrTag[0] = 'pageimage_path';

or later on pageimage_src should be transformed to pageimage_path for example.