1

One of my channels allow users to upload images. Two problems:

  1. I've defined a max width and height in the file upload preferences (and my channel field uploads to that). However, I am able to upload images beyond the max width and height.
  2. When I am displaying this image to the browser, how do I get the image's width and height? The following doesn't work:

<img src="{banner_image}" width="{width}" height="{height}" alt="{alternate_text}"></img>

6

Assuming you are using the ExpressionEngine File Fieldtype... In answer to #2, take a look at the documentation for the file field.

Specifically, the variable pair usage will allow you to pull in the width and height.

{banner_image}
    <img src="{url}" width="{width}" height="{height}">
{/banner_image}

I can't speak with much experience to question #1 since I've long disregarded the setting for max width and height in file upload preferences in favor of using plugins like CE Image (highly recommended!), but if you need specific sizes without using an add-on you can use the Image Manipulations feature that is built into EE. Once you have those set up, an image at a particular size is available by name like this {banner_image:custom_size_name}.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.