CGBlog and images extra field [SOLVED]

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
sam_m
Forum Members
Forum Members
Posts: 34
Joined: Thu Jun 11, 2009 11:59 pm

CGBlog and images extra field [SOLVED]

Post by sam_m »

Hello, I wonder if someone could help with the code for this please, ive got it working with Supersizer for one image, but cant figure out how it works using the created thumbnail and full size image without the need for supersizer...

I`ve added 3 extra image fields for CGBlog, but im trying to get the summary to just show the thumbnail of the first image uploaded, but when in the detail mode to show the full size of all 3 images uploaded.

Ive been through countless threads on this forum in hope I can get the answer, but im not getting very far with it, if it is possible at all.

Any advise would be greatly appreciated
Thank you
Sam
Last edited by sam_m on Mon Jul 11, 2011 12:16 am, edited 1 time in total.
sam_m
Forum Members
Forum Members
Posts: 34
Joined: Thu Jun 11, 2009 11:59 pm

Re: CGBlog and images extra field [SOLVED]

Post by sam_m »

OK I think ive solved it....

Summary template..

{if !empty($entry->fieldsbyname.image1->value)}
<a href="{$entry->detail_url}"><img src="{$entry->file_location}/thumb_{$entry->fieldsbyname.image1->value}" width=100px /></a>
{/if}


and then in the detail template...

{if !empty($entry->fieldsbyname.image1->value)}
<a href="{$entry->detail_url}"><img src="{$entry->file_location}/preview_{$entry->fieldsbyname.image1->value}" width=100% /></a>
{/if}
<br><br>
{if !empty($entry->fieldsbyname.blog_image2->value)}
<a href="{$entry->detail_url}"><img src="{$entry->file_location}/preview_{$entry->fieldsbyname.blog_image2->value}" width=100% /></a>
{/if}
<br><br>
{if !empty($entry->fieldsbyname.blog_image3->value)}
<a href="{$entry->detail_url}"><img src="{$entry->file_location}/preview_{$entry->fieldsbyname.blog_image3->value}" width=100% /></a>
{/if}


Seems to be working
User avatar
ncp911
Forum Members
Forum Members
Posts: 18
Joined: Mon Nov 17, 2008 8:06 pm
Location: Florida, USA

Re: CGBlog and images extra field [SOLVED]

Post by ncp911 »

I was wondering if you could share how you entered the extra image fields in cgBlog
sam_m
Forum Members
Forum Members
Posts: 34
Joined: Thu Jun 11, 2009 11:59 pm

Re: CGBlog and images extra field [SOLVED]

Post by sam_m »

ncp911 wrote:I was wondering if you could share how you entered the extra image fields in cgBlog
Hello, no problem...

in the field definitions within the CGBlog, click on add field definition and call it any name you like, ill use (image1)

Make sure you choose the type as being image, and I set the thumbnail and preview to being yes. This creates a browse button within the page where you add a new article.

Once your field definition is setup its just a matter of using the code I used below (might be better ways but this works perfectly for me)...

so in the summary if you wanted image1 to show up as a thumbnail...

{if !empty($entry->fieldsbyname.image1->value)}
<a href="{$entry->detail_url}"><img src="{$entry->file_location}/thumb_{$entry->fieldsbyname.image1->value}" width=100px /></a>
{/if}

thumb_ being the thumbnail generated from uploaded the image within the blog article, and I just set a width of 100px so the thumbnail doesnt display over this size.

You can place this wherever you want in the summary template.

Then in the detail template I added this right at the bottom...

{if !empty($entry->fieldsbyname.image1->value)}
<a href="{$entry->detail_url}"><img src="{$entry->file_location}/preview_{$entry->fieldsbyname.image1->value}" width=100% /></a>
{/if}

Similar too before, but it just takes the preview image that was generated automatically from the original file and ive set it to display as 100% so it fits within the DIV container of the layout no matter what size its been set. You can play around with this and have a set size in px if you wanted too.

I wanted the larger images to automatically display below any content I had written in the blog, so this was added to the bottom of the detail template.

And thats it really, if you want more images just add more field definitions using a different name, so for example image2, image3 and so on.

Kind Regards
Sam
User avatar
ncp911
Forum Members
Forum Members
Posts: 18
Joined: Mon Nov 17, 2008 8:06 pm
Location: Florida, USA

Re: CGBlog and images extra field [SOLVED]

Post by ncp911 »

Awesome Thanks. I can see a bunch of opportunities to use this. To have a structured "Featured Image" kinda like WP or using a summary field template as a slider template. This would be awesome. Thanks again.
Post Reply

Return to “Modules/Add-Ons”