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

Need the ability to add {width} and {height} attribute to generated <img />

Development and Programming

Cog Design's avatar
Cog Design
10 posts
16 years ago
Cog Design's avatar Cog Design

Hi Mark,

I work for a company called Cog Design, and we are using your extension on a site we are building. So far, it has been very helpful (much easier to use then EE’s standard file upload).

However, I need a way to generate the width and height attribute for the uploaded image, once it is fed through to the page.

Within the file upload preferences, I have set it not to resize images, or generate a thumbnail.

Within the page, I have put the following code:

{exp:weblog:entries weblog="{my_weblog}" disable="member_data|categories|pagination|trackbacks" status="open" limit="1"}
<h1>{title}</h1>
{generic_body}

{if generic_image!=''}
{generic_image}
{file_url}
{/generic_image}
{/if}                

{/exp:weblog:entries}

I just need a way of dynamically inserting the width and height attributes for the image. Hope you can help!

Thanks,

Jack, Cog Design

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Hi Jack,

By extension I am guessing that you are referring to the File extension by Mark Huot perhaps? If so then that is a 3rd party extension which wasn’t developed by EllisLab.

Saying that however I don’t think that the extension has any variables for height and width in it so you are probably going to need to use some PHP to take the path of the image and then spit out the values for you in that way.

I have some sample code to take an image path and get the sizes for you shown below if you want to use that.

<?php
$imageurl ="http://www.example.com/images/photos/{image-url}";
list($width, $height, $type, $attr) = getimagesize("$imageurl");
?>

You can then output the details like this further in your template :

<?php
echo $width;
echo $height;
?>

Hope that helps a bit.

Best wishes,

Mark

       
Cog Design's avatar
Cog Design
10 posts
16 years ago
Cog Design's avatar Cog Design

Hi Mark,

Apologies for my late reply, I have yet to try implementing this, but thanks so much for helping me even though I posted to the wrong area in the forum! I will let you know how the fix goes.

Thanks,

Jack

       

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.