Forum
Original image field Illegal string offset '_default'
Hello, for some reason just recently I'm getting an error on my blog post page. The second line is causing the error:
$customimg_1 = perch_blog_post_field(perch_get('s'), 'featureimage', true);
$customimg = $customimg_1['_default'];
The error I'm getting is:
Warning: Illegal string offset '_default' in /nfs/c11/h02/mnt/191364/domains/[website.com]/html/post.php on line 8
This was getting the original uploaded image as apposed to the resized version. Any ideas?
You're asking for
$customimg_1['_default']
but$customimg_1
doesn't have a key called_default
.Oh ok, strange, did something change as I'm sure this was working?
Is there a way to get the value of the original version of the image and not the resized version?
What's the value of
$customimg_1
?It's just returning the cropped version of the image, Eg. "/perch/resources/imagename-w120h120.jpg"
So this line isn't returning an array like I believe it was before.
In my post.html template I have the following:
I use the 120x120 version and the 80x80 version in different templates, which work well. Is there any way I can get the original version of the image specially on the blog post page?
Before what change?
You probably don't want the actual original, as that could be any crazy size. If you add a new size to your template, I believe
perch_blog_post_field()
will return the first instance.