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

sql query for channel field image

Development and Programming

stevo_s's avatar
stevo_s
176 posts
14 years ago
stevo_s's avatar stevo_s

How do I get the file name for a channel image field {thumbnail} that is in a channel using sql query? When I look in SQL manager the image file appears like this in exp_channel_data field_id_6:

https://ellislab.com/asset/images/team-photo/13.jpg

rather than 13.jpg

the exp_channel_data channel_id is 3

Do I need to do a JOIN with exp_files - file_name ? ( I only want images from that channel 3 though).

I’m trying to grab the 4 last images posted to a channel - 1 per author.

this doesn’t seem to work:

{exp:query sql="SELECT file_name FROM exp_files 
WHERE exp_channel_data.channel_id='3' LIMIT 4"}
{file_name} alt=
{/exp:query}

[Mod Edit: Moved to the Development and Programming forum]

       
the3mus1can's avatar
the3mus1can
426 posts
14 years ago
the3mus1can's avatar the3mus1can

You might want to look at this thread: Remove the filedir_1 from the start of the rendered sql call

       
stevo_s's avatar
stevo_s
176 posts
14 years ago
stevo_s's avatar stevo_s

Ok, thanks. Do you have to hard code the url to a file as {path= doesn’t seem to work as it put /index.php at the end ?

       
the3mus1can's avatar
the3mus1can
426 posts
14 years ago
the3mus1can's avatar the3mus1can

You could use {site_url}.

       
stevo_s's avatar
stevo_s
176 posts
14 years ago
stevo_s's avatar stevo_s

thanks.

       

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.