Page 1 of 1
Content Image not working after upgrade to 2.2.1
Posted: Fri Jun 30, 2017 1:56 am
by Simon66
I upgraded a site from 2.1.6 to 2.2.1.
My page template includes a Content Image:
Code: Select all
{capture assign='contentimage'}{content_image block='Content Image' dir='images/Gallery/content_images' urlonly='1' exclude='thumb_'}{/capture}
If I choose a Content Image in a page of the Content Manager (very cool new file picker BTW) and submit the changes, there is no image on the front end.
Then I open the page again in the Content Manager and there is a '0' in the Content Image field.
Cheers
Simon66
Re: Content Image not working after upgrade to 2.2.1
Posted: Mon Jul 03, 2017 8:10 am
by scooper
We had something similar when we upgraded a site.
It looks as if in the old dropdown image selector the default was '-1' and in the smart new image picker it's '0' if there was no image selected
In our template we were looking to see if the image wasn't -1 and then displaying it if not which not longer worked.
Now that's slightly different to your case where the image doesn't appear to be being saved but we also use a slightly different method of accessing the image so maybe that's changed too.
The code that works for us at the moment is:
Code: Select all
{assign var=banner_image value=$content_obj->GetPropertyValue('image')}
{if !empty($banner_image) && $banner_image ne -1}
show the image or whatever.
{/if}
Give that a go and see if it helps.
s.
Re: Content Image not working after upgrade to 2.2.1
Posted: Mon Jul 03, 2017 9:12 am
by Rolf
I noticed this too with regular content blocks. Looks like a change in Smarty... Block names doesn't allow spaces anymore.
{content_image block='Content Image' ...}
should become:
{content_image block='Content_Image' ...}
But don't change the code in the template, first keep both tags in there! Otherwise you might lose your settings/content.
Rolf
SOLVED: Content Image not working after upgrade to 2.2.1
Posted: Mon Jul 03, 2017 1:07 pm
by Simon66
Thanks Scooper and Rolf,
I first tried changing the block name suggested by Rolf as it was the simplest change and it worked.
I had to add the label but it works perfectly now.
Code: Select all
{capture assign='contentimage'}{content_image label="Content Image:" block='Content_Images' dir='images/Gallery/content_images' urlonly='1' exclude='thumb_'}{/capture}
Cheers
Simon66
Re: Content Image not working after upgrade to 2.2.1
Posted: Mon Jul 03, 2017 7:18 pm
by Rolf
Code: Select all
{capture assign='contentimage'}{content_image label="Content Image:" block='Content_Images' dir='images/Gallery/content_images' urlonly='1' exclude='thumb_'}{/capture}
A bit shorter and easier to process:
Code: Select all
{content_image label="Content Image:" block='Content_Images' dir='images/Gallery/content_images' urlonly='1' exclude='thumb_' assign='contentimage'}
I personnaly prefer:
Code: Select all
{$contentimage = "{content_image label='Content Image:' block='Content_Images' dir='images/Gallery/content_images' urlonly='1' exclude='thumb_'}"}
Because you can add more parameters afterwards, i.e.:
Code: Select all
{$contentimage = "{content_image label='Content Image:' block='Content_Images' dir='images/Gallery/content_images' urlonly='1' exclude='thumb_'}" scope=global}
Re: Content Image not working after upgrade to 2.2.1
Posted: Mon Jul 03, 2017 10:34 pm
by Simon66
Thanks Rolf,
The only reason I did it the old way is because it's the one I learned when I started using CMSms.
I will add your preferred method to my tool kit.
Cheers
Simon66