Using the WideImage extension, I am attempting to render an Image Blob from the database using this function:
protected function renderControlNonEditable()
{
assert('$this->model instanceof Item || $this->model->getModel() instanceof Item');
$content = null;
if ($this->model->files->count() > 0)
{
$content .= '<ul class="attachments">';
foreach ($this->model->files as $fileModel)
{
$filecontent = FileContent::getById($fileModel->id);
$filecontent = $filecontent->content;
$content .= '<li><span class="icon-attachment"></span>';
$content .= FileModelDisplayUtil::renderDownloadLinkContentByRelationModelAndFileModel($this->model,
$fileModel);
$content .= ' ' . FileModelDisplayUtil::convertSizeToHumanReadableAndGet((int)$fileModel->size);
$content .= '</li>';
$content .= WideImage::load($filecontent);
}
$content .= '</ul>';
}
return $content;
}
But when the $content
is rendered it shows the following BLOB string instead of rendering the image.
�PNG IHDRd$��8:IDATh�ݛy|Օ����
How can I ensure the proper headers are being issued? What can I do to fix this?
public function actionImage($model, $fileModel)
{
$filecontent = FileContent::getById($fileModel->id);
$filecontent = $filecontent->content;
$content = WideImage::load($filecontent);
return $content;
}