Error when outputting a file type custom attribute

Permalink Browser Info Environment
When I select a custom attribute that's a file type (image), I get this error:

Catchable fatal error: Object of class File could not be converted to string in packages/ryan_page_value/blocks/ryan_page_value/controller.php on line 62

Type: Discussion
Status: In Progress
RebeccaSt
View Replies:
ryan replied on at Permalink Reply
ryan
Yeah, it currently doesn't do images/files.

This code below should do what you're looking for.

Add a file to your site at:
[site root]/blocks/ryan_page_value/templates/image_file.php

with this code.
<?php defined('C5_EXECUTE') or die(_("Access Denied."));
echo $this->controller->getOpenTag();
echo $this->controller->getTitle();
$f = $this->controller->getContent();
if($f instanceof File) {
   $ih = Loader::helper('image');
   $ih->output($f);
} else {
   echo $f;
}
echo $this->controller->getCloseTag();
?>


That should do it, and I'll test this and add it to the package next time I get a few minutes.
ConcreteCMS replied on at Permalink Reply
ConcreteCMS
Attention: Since there has been no activity on this issue for two weeks, this issue has been automatically archived.

To re-open this issue, reply to this message.
thebogdan replied on at Permalink Reply
thebogdan
Hi, I'm getting a similar error message, even after adding the image_file.php as instructed above.

Error:

Warning: strlen() expects parameter 1 to be string, object given in /public_html/packages/ryan_page_value/blocks/ryan_page_value/controller.php on line 62

I'm trying to output contents of an attached HTML file. Also, my C5 version is 5.6.3.3 -- does that matter at all?
Korvin replied on at Permalink Reply
Korvin
I'd open a new support ticket.

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.