We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Displaying just 1 thumbnail for 'File'

Development and Programming

Nick Foxall's avatar
Nick Foxall
189 posts
16 years ago
Nick Foxall's avatar Nick Foxall

I’m using File 3.1.1 on a site, set to upload multiple images, and create multiple thumbnails. Seems to work okay (after much hair-pulling – this must be the most frustrating EE extension in the entire EE universe!!).

I just need to know how to bring up just one thumbnail on a directory listing page I’ve built. When the user goes to a detail page, they can see all the thumbnails (and click for original images), but on the directory page, I just want to show the first uploaded thumbnail.

The tag works if I just want to display the first image (i.e. the first full size image), such as in…

{myimage}

…(where “myimage” is the custom field name) but how do you configure the tags to pull up just the first thumbnail? Is there a parameter you can use with {file_thumb_url}? If so, how is the code written?

Thanks!!

PS: where can I get the extended version of File (4.2)?

       
Rob Allen's avatar
Rob Allen
2,950 posts
16 years ago
Rob Allen's avatar Rob Allen

This should display the thumbnail for you

{myimage}{file_thumb_url}{/myimage}
       
Nick Foxall's avatar
Nick Foxall
189 posts
16 years ago
Nick Foxall's avatar Nick Foxall

Thx bluedreamer…..

I tried that and it works…. for ALL thumbnails. if you upload multiple images using ‘File’ (I’m telling the client to upload 6 images) that code displays the thumbnails of all 6 images.

What if I just want to display the first thumbnail from the upload, not all 6? I want it for a search results page, so I just need to show one thumbnail. The user can then click through to view all 6.

Cheers,

Nik

       
Rob Allen's avatar
Rob Allen
2,950 posts
16 years ago
Rob Allen's avatar Rob Allen

Ah yes of course, sorry wasn’t thinking straight!

I don’t think you can call one thumb when there are multiple images, there might be a way with some conditional but I haven’t got time at the mo’ to work out what’s what.

What I did on a recent project was to have two custom image fields. The first field is the “default image” (only one image allowed), and the second field for all extras. That makes calling the thumb of the default image a lot easier.

       
Nick Foxall's avatar
Nick Foxall
189 posts
16 years ago
Nick Foxall's avatar Nick Foxall

Actually, I got a solution from someone else. I posted the same question back in the File forum thread here and someone came back with using the {count} variable.

For me it worked like this:

{studioimage}{if count == 1}
<a href="http://{title_permalink=English/artistdetails}">{file_thumb_url}</a>{/if}
{/studioimage}

Notice the src is still calling the {file_thumb_url}, but the {count} is limiting it to the first uploaded thumb in the list.

I was also able to wrap this entire code in another {if} conditional, so if there were no thumbnails available (that is, no image files uploaded for that record), it would just show a placeholder image.

Neat, eh? N

       
ResonateOrDie's avatar
ResonateOrDie
3 posts
16 years ago
ResonateOrDie's avatar ResonateOrDie

Nick - I’m having the opposite problem. I can’t get more than one image to show. I want to show all of the images that i upload, per entry. It’s only showing 1. I have selected ‘allow multiple uploads’. I have tried using the multi tag mentioned by Mark.

My image custom field is {portfolio_screenshot}. When I try something like {portfolio_screenshot}{file_url}{/portfolio_screenshot}, it shows all the urls jammed together. I’ve been reading and reading and can’t figure it out.

Any insight would be appreciated.

Thanks

       
Nick Foxall's avatar
Nick Foxall
189 posts
16 years ago
Nick Foxall's avatar Nick Foxall

kbural - tell me about it! Its the most frustrating extension out there, cos (1) the documentation is scant at best, and (2) the extension itself is no longer supported, and (3) there really is no other viable system in EE at present.

Try this:

{portfolio_screenshot}
{file_thumb_url}
{/portfolio_screenshot}

Use the {file_thumb_url} variable INSIDE an <img > tag. And wrap it all in your custom fieldname (portfolio_screenshot} ….. {/portfolio_screenshot}.

If you want to link the images to something else (an enlargement, etc) – and most times you usually do – try this:

{portfolio_screenshot}
<a href="http://{file_url}">{file_thumb_url}</a>
{/portfolio_screenshot}

wrap the img tab in an <a> link tag, where the actual link is to {file_url}. This will link to the original uploaded image. You can add CSS classes to style as desired. Also works for java galleries like FancyBox.

Nick

       
ResonateOrDie's avatar
ResonateOrDie
3 posts
16 years ago
ResonateOrDie's avatar ResonateOrDie

Thank you so much! That worked. So appreciate it.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.