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

Re: Mark Huot file ext. Question: Need to dynamically assign width and height attribute to file generated image

Development and Programming

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

Hi Mark,

I’m using your file extension (which is a godsend by the way!) to upload PNG’s to the page, then am using jQuery png fix to render them correctly in IE6.

My problem is that in order for the jQuery png fix to work properly the embedded <img > must have a width and height attribute.

Is there a way within the FILE extension, to dynamically add width and height to the embedded image?

I already posted this question (but on the wrong part of the forum, I’m a forum beginner you see!) and was offered a solution that utilises PHP.

Does your extension pull in width and height anyway, without having to use extra PHP?

I have set up the extension like so:

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 hope this is enough information to go on. I look forward to your reply,

Thanks,

Jack - Cog Design

       
lukemcr's avatar
lukemcr
154 posts
16 years ago
lukemcr's avatar lukemcr

Any progress on this? I’d love to be able to access the image sizes from within the File plugin tags.

       
Chris Newton's avatar
Chris Newton
440 posts
16 years ago
Chris Newton's avatar Chris Newton

That’s a very interesting question. I hadn’t thought of that problem. I’ll spend an hour tonight on it, and see if I can make a modification that might work for you.

       
lukemcr's avatar
lukemcr
154 posts
16 years ago
lukemcr's avatar lukemcr

That would be fantastic - thank you. 😊

In the meantime, I’ve found that the Image Resize plugin works fine from within the File plugin tags. Image Resize has {height} and {width} tags that can be parsed by File. It worked for what I was trying to do with it, anyway.

       
Chris Newton's avatar
Chris Newton
440 posts
16 years ago
Chris Newton's avatar Chris Newton

Around line 1225, find this;

$var = array(
                        'count' => $count+1,
                        'total_results' => $total_results,
                        'file_name' => $file,
                        'file_url' => $FNS->remove_double_slashes($file_field['url'].'/'.$file),
                        'file'.$this->thumb_suffix.'_name' => $thumb,
                        'file'.$this->thumb_suffix.'_url' => $thumb_url
                    );

change to this:

list($mh_file_width, $mh_file_height) = getimagesize($FNS->remove_double_slashes($file_field['url'].'/'.$file));
                    
                    $var = array(
                        'count' => $count+1,
                        'total_results' => $total_results,
                        'file_name' => $file,
                        'file_url' => $FNS->remove_double_slashes($file_field['url'].'/'.$file),
                        'file'.$this->thumb_suffix.'_name' => $thumb,
                        'file'.$this->thumb_suffix.'_url' => $thumb_url,
                        'file_width' => $mh_file_width,
                        'file_height' => $mh_file_height
                    );

If you use the variable pairs, you can access the width with: file_width, and height with: file_height

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

Hi Chris,

This solution sounds great, thanks for taking the time to work this out, can’t wait to try! and thanks Luke for taking an interest too, always great to build on a good extension!

Jack

       
Eastwood Design's avatar
Eastwood Design
605 posts
16 years ago
Eastwood Design's avatar Eastwood Design

is there a way to also add a filed to the file upload that you can use as a title?

Lets say you want to upload 5 pdf’s and you use the file upload allowing for multiple files. No trouble getting the files up, but what is you want to display a little text like a title for each one of those files, is there any way to do that?

       
lukemcr's avatar
lukemcr
154 posts
16 years ago
lukemcr's avatar lukemcr
is there a way to also add a filed to the file upload that you can use as a title? Lets say you want to upload 5 pdf’s and you use the file upload allowing for multiple files. No trouble getting the files up, but what is you want to display a little text like a title for each one of those files, is there any way to do that?

There’s an unofficial modification of the File extension that lets you do this. It adds title and caption fields directly beneath the file upload space. See http://ellislab.com/forums/viewthread/38997/P738/; boswebdev made it.

It’s a little bit buggy, I’ve found, but it might be exactly what you need.

       
Chris Newton's avatar
Chris Newton
440 posts
16 years ago
Chris Newton's avatar Chris Newton

I have a modified version of the file mentioned above, that’s NOT buggy. PM me and I’ll send it to you.

I also have a modded vs. of Huot’s file upload with some bugs fixed as well. I sent Mark Huot an email asking if I could release them, and as expected I didn’t hear back. I’m sure he’s very busy, and is probably sick of hearing about his stuff 😊 I don’t see any reason not to upload a fixed version of it though. If I had time, I’d rewrite it from the ground up so it’d be a new release with a new name so people wouldn’t get confused… but I think it’s kinda important to get the bug fixes out.

       
notacouch's avatar
notacouch
92 posts
16 years ago
notacouch's avatar notacouch
is there a way to also add a filed to the file upload that you can use as a title? Lets say you want to upload 5 pdf’s and you use the file upload allowing for multiple files. No trouble getting the files up, but what is you want to display a little text like a title for each one of those files, is there any way to do that?

I’m interested in the mods mentioned above but so far I’ve been using a heavily modified version of Mark Huot’s MultiText which seems to be obsolete courtesy LG Data Matrix (I think that was the name, am looking forward to using it on a future project). I would just store multitext fields in an array via php and when printing out each File image refer to the array with an index of {count} for the title, alt, and/or caption.

I just recently made a plugin that I realized you could inadvertently possibly store that stuff without using PHP on the template but I haven’t tested that out yet (it’s meant for search/replace templated code come to think of it it was specifically for capturing a div from file and putting it inside content).

       
Chris Newton's avatar
Chris Newton
440 posts
16 years ago
Chris Newton's avatar Chris Newton

For those of you that asked about my non-buggy version of this, please see: http://ellislab.com/forums/viewthread/106137/

       

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.