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 images from a fluid field

How Do I?

bijan's avatar
bijan
5 posts
4 years ago
bijan's avatar bijan

Hello, I am fairly new to EE and I am testing out fluid fields. I tried reading through the documentation but was unable to solve my problem. I currently have a fluid field that can take in an image, however when I try and display that image nothing appears on the screen.

I am able to get text output, it’s just the image that I’m having problems with.

My current code is :

{exp:channel:entries channel="results"}
{fluid_field_test}
 {fluid_field_test:featured_image}
     {content}
   {content:featured_image}
     {/content}
   {/fluid_field_test:featured_image} 
{/fluid_field_test}
{/exp:channel:entries}

Any help would be appreciated, thanks!

       
Robin Sowell's avatar
Robin Sowell
13,158 posts
4 years ago
Robin Sowell's avatar Robin Sowell

I think you’re really close. The fluid field is named ‘fluid_field_test’ and the file field is named ‘featured_image’ - right?

If so, try:

{fluid_field_test}
  {fluid_field_test:featured_image}
    {content}
      Extension: {extension}
      Upload date: {upload_date format="%Y %m %d"}
      URL: {url}
    {/content}
  {/fluid_field_test:featured_image}
{/fluid_field_test}
       
bijan's avatar
bijan
5 posts
4 years ago
bijan's avatar bijan

Yes, the field names are ‘fluid_field_test’ and ‘featured_image’. Unfortunately, this code still doesn’t display the image. It does however grab the correct content for the extension/date/URL.

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

That’s good because Robins code works - there’s no img tag in there.

Try this, I’ve replaced values with an image tag:

{fluid_field_test}
  {fluid_field_test:featured_image}
    {content}
      < img src="{url}" width="{width}" height="{height}" alt="{title}" >
    {/content}
  {/fluid_field_test:featured_image}
{/fluid_field_test}
👍 1
       
bijan's avatar
bijan
5 posts
4 years ago
bijan's avatar bijan

Hey there, thanks for this (it worked). You wouldn’t happen to know how to display from a fluid file grid, would you?

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

Sure, the file grid field has a reserved name for the file field, so if featured_image is the name of your file grid, you could do something like this:

{fluid_field_test}
  {fluid_field_test:featured_image}
    {content}
      < img src="{file}" width="{width}" height="{height}" alt="{title}" > // where {file} is the file grid file field name
    {/content}
  {/fluid_field_test:featured_image}
{/fluid_field_test}
       
bijan's avatar
bijan
5 posts
4 years ago
bijan's avatar bijan

This didn’t seem to work for me. Not sure why. Is the file grid file field name always {file}? I tried a few different variations of what I thought it could be but no images are displayed.

{fluid_field_test}

    {fluid_field_test:fluid_file_grid}

    {content}
     < img src="{file}" width="{width}" height="{height}" alt="{title}"/ >
    {/content}

   {/fluid_field_test:fluid_file_grid}

{/fluid_field_test}
       
bijan's avatar
bijan
5 posts
4 years ago
bijan's avatar bijan

I figured this out by the way, the answer for anyone that may need it:

<figure> {exp:channel:entries channel="CHANNEL-NAME"}

{ FIELD-NAME }
 < img src="{FIELD-NAME:file}" >
{ /FIELD-NAME }

{/exp:channel:entries} </figure>

       

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.