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

Edit File Upload Preferences & Height/Width

How Do I?

ThePixelPusher's avatar
ThePixelPusher
82 posts
10 years ago
ThePixelPusher's avatar ThePixelPusher

Hi,

I’m trying to add the image width and height in an image that has been uploaded via a channel file field, how do I pull this info out dynamically?

I couldn’t find anything online about it.

       
Boyink!'s avatar
Boyink!
5,011 posts
10 years ago
Boyink!'s avatar Boyink!

Use an image manipulation and then width and height are available as variables in the File Field tag pair:

https://ellislab.com/expressionengine/user-guide/add-ons/channel/custom_fields.html#file-field

       
ThePixelPusher's avatar
ThePixelPusher
82 posts
10 years ago
ThePixelPusher's avatar ThePixelPusher

Oh I see so don’t use the one I initially upload, just one of the ones I have manipulated? Ok I’ll try that.

       
Boyink!'s avatar
Boyink!
5,011 posts
10 years ago
Boyink!'s avatar Boyink!

Actually, I think if you just use the File variable pair you can use the width and height variables. No manipulation needed.

       
ThePixelPusher's avatar
ThePixelPusher
82 posts
10 years ago
ThePixelPusher's avatar ThePixelPusher

Hmm, I tried this.

{project_feature_image:feature_large}
       
Boyink!'s avatar
Boyink!
5,011 posts
10 years ago
Boyink!'s avatar Boyink!

It didn’t work because you didn’t use the tag pair.

       
ThePixelPusher's avatar
ThePixelPusher
82 posts
10 years ago
ThePixelPusher's avatar ThePixelPusher

Got it, awesome thanks. Really feel I am starting to get the hang of this now.

       
Boyink!'s avatar
Boyink!
5,011 posts
10 years ago
Boyink!'s avatar Boyink!

Cool - glad to hear it!

       
ThePixelPusher's avatar
ThePixelPusher
82 posts
10 years ago
ThePixelPusher's avatar ThePixelPusher

Just when I think I have it. :(

I have created a channel for my Site Branding, and a channel field called Site Logo.

Here is my code to pull it through.

{exp:channel:entries channel="site_branding" limit="1"}
    {site_logo}
        {site_logo:normal}
    {/site_logo}
{/exp:channel:entries}

I have an image manipulation setup. Shortname normal set to constrain with width and height set at 96px.

It is displaying the image with width and height of 400px. Which is what the original image I uploaded is set at.

I deployed this same tactic on other elements on the page and they work fine, this has stumped me.

EDIT:

Actually saying that, I just checked the others on the page with the different image manipulation and the width and height are pulling in the same as the big image. So I’m missing something here.

       
Boyink!'s avatar
Boyink!
5,011 posts
10 years ago
Boyink!'s avatar Boyink!

Hmm - I have never done it but you might have to use the image manipulation as the tag pair:

{site_logo:normal} {/site_logo:normal}

But…

While you certainly can store your site branding in a channel and call it dynamically, what are the odds it will ever change?

You’re adding a number of queries to every page load on the off chance that down the road somewhere you (or a client) can load in a new logo.

What I would suggest instead is hardcoding the logo and any other branding elements not likely to change into a Snippet or Embedded template that gets called from all other templates. This way you’d still have just one place to change out the logo file name and the amount of overhead added to each page load would be much less.

       
ThePixelPusher's avatar
ThePixelPusher
82 posts
10 years ago
ThePixelPusher's avatar ThePixelPusher

Ok, I tried adding the image manipulation as a pair, no dice.

Your probably right about the logo.

       

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.