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

File

Development and Programming

Matt Weinberg's avatar
Matt Weinberg
489 posts
16 years ago
Matt Weinberg's avatar Matt Weinberg

No problem. I use a conditional with File in my templates all the time. If your FIle custom field is named imageUpload, you can do:

{if imageUpload != ""}{imageUpload}{file_thumb_url}{/imageUpload}{/if}

One piece of advice: don’t use if:else with them, only simple {if}{/if} conditionals (you can use {if imageUpload != ""}foo{/if}{if imageUpload == ""}bar{if}). I’ve seen weirdness when using the advanced conditionals with it.

       
George Ornbo's avatar
George Ornbo
272 posts
16 years ago
George Ornbo's avatar George Ornbo

Firstly to Mark Huot a big THANK YOU for publishing this extension. It is great.

I’ve got an issue that seems to have cropped up before but doesn’t seem to have found a resolution yet.

Via the First Party uploader I can upload images and resize them correctly and they output with the correct MIME type. Using the file extension I am coming across an issue where the resized file is resizing ok but taking the incorrect MIME type. So I’ve got a .jpg file with a MIME type of GIF. I’ve run a few tests and any image file uploaded gets the MIME type of GIF.

I’m using the GD2 Library for the resizing and have the following config in phpinfo()

GD Support     enabled
GD Version     bundled (2.0.28 compatible)
FreeType Support     enabled
FreeType Linkage     with freetype
FreeType Version     2.2.1
GIF Read Support     enabled
GIF Create Support     enabled
JPG Support     enabled
PNG Support     enabled
WBMP Support     enabled
XBM Support     enabled

I’m running this on Apache 2.2.3, PHP 5.1.6 on Centos 5.2

Looking through the extension code I’m not sure that MIME type gets set?

       
Deron Sizemore's avatar
Deron Sizemore
1,033 posts
16 years ago
Deron Sizemore's avatar Deron Sizemore
No problem. I use a conditional with File in my templates all the time. If your FIle custom field is named imageUpload, you can do:
{if imageUpload != ""}{imageUpload}{file_thumb_url}{/imageUpload}{/if}
One piece of advice: don’t use if:else with them, only simple {if}{/if} conditionals (you can use {if imageUpload != ""}foo{/if}{if imageUpload == ""}bar{if}). I’ve seen weirdness when using the advanced conditionals with it.

Good to know! Thanks for the heads up and info. 😉

       
kevincannon's avatar
kevincannon
22 posts
16 years ago
kevincannon's avatar kevincannon

Great extension - you’ve saved me a world of hassle with this - thanks!

Having a small problem in that the image resize method defaults to Auto all the time and I can’t seem to change it. I have Max Width and Min Width set, but every time I go back to the file upload preferences it still says Auto.

Is there a setting I’m missing? Everything else works fine.

       
Thorvalt's avatar
Thorvalt
23 posts
16 years ago
Thorvalt's avatar Thorvalt

Hello all,

I try to make transparent png thumbs but if they are created they have a black background After a quick google i came on this: http://www.akemapa.com/2008/07/10/php-gd-resize-transparent-image-png-gif/

I’ve tried to edit the extension but with no luck.

Someone who can help me with this to get it working? Thanks!

       
Thorvalt's avatar
Thorvalt
23 posts
16 years ago
Thorvalt's avatar Thorvalt

Hi people, me again, i have now this code (Check if this image is PNG, then set it to transparent):

//  =============================================
                    //  Create Destination Image
                    //  =============================================

                    $dst_img = $create($dst_width, $dst_height);
                    
                    //  =============================================
                    //  Check if this image is PNG, then set it to transparent
                    //  =============================================                    
                    if(($src_img = @imagecreatefrompng($server_path.$file_name)) !== FALSE) {
                        imagealphablending($dst_img, false);
                        imagesavealpha($dst_img,true);
                        $transparent = imagecolorallocatealpha($dst_img, 255, 255, 255, 127);
                        imagefilledrectangle($dst_img, 0, 0, $dst_width, $dst_height, $transparent); 
                    }
                    
                    //  =============================================
                    //  Copy SRC to DEST
                    //  =============================================
                    $copy($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_width, $dst_height, $src_width, $src_height);
                    
                    //    =============================================

Can somebody tell me what i’m doing wrong here?

       
Matt Weinberg's avatar
Matt Weinberg
489 posts
16 years ago
Matt Weinberg's avatar Matt Weinberg
Is there a setting I’m missing? Everything else works fine.

Are you seeing the settings listed here:

http://docs.markhuot.com/ee/extensions/file/

There’s a glitch in the extension where those settings can be hidden sometimes, and you have to set them via the database. Where are you setting auto?

-Matt

       
Tyssen's avatar
Tyssen
756 posts
16 years ago
Tyssen's avatar Tyssen

Apologies if this has been asked before (but it’s a very long thread): is there a way to be able to upload files with the same name over the top of ones that already exist? By default it throws an error message about duplicate file names.

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

Hi Tyssen,

Well there are two things that you can do about that. One is that when you get the warning you can click on the check-box that appears at the top of the publish page and then choose the image / file again and re-upload it. You should then notice that the file now gets called the same name but with something like _1 appended to the end of the name before the file extension.

The other way is to use the option in the File extension to make it re-name all files for you anyway. This means that any file that gets uploaded is completely renamed and has loads of numbers and letters in its file-name. If you aren’t fussed about what the files are called then this is the absolute easiest way to go but if you are going to need to be able to find the images / files at a later date then this could cause problems. Both have their merits in one way or the other but totally depends on which way you need to use the files once they are uploaded.

Hope that helps.

Best wishes,

Mark

       
Tyssen's avatar
Tyssen
756 posts
16 years ago
Tyssen's avatar Tyssen

Not really, because I have one part of a site I’ve been working on where the navigation is based on the file name so it needs to be in the same format and if the client ever needs to replace a file, they should be able to upload a new one with the same name and replace the previous one (although they’re unlikely to do it very often and the files are on the large size, so it may just be easier to FTP new files over the top of the old ones).

       
Matt Weinberg's avatar
Matt Weinberg
489 posts
16 years ago
Matt Weinberg's avatar Matt Weinberg

Tyssen– why not delete the file using the extension, the reupload the new one? If it’s the same name your navigation should still work.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen
Tyssen– why not delete the file using the extension, the reupload the new one? If it’s the same name your navigation should still work.

That would have been my next suggestion but I wasn’t sure if the file you were trying to upload with the same name was in the same entry or not though?

If it is indeed in the same entry then no problem just go ahead and click on the remove check-box and then choose the new (same-named) image and everything should be fine. If the image / file is in another entry then you wouldn’t be able to do this as you wouldn’t be able to have two files of the same name in the same upload directory.

Best wishes,

Mark

       
grantmx's avatar
grantmx
1,439 posts
16 years ago
grantmx's avatar grantmx

Cool plugin. One can write a whole new Wiki just based off of the 30+ pages of tech support in this thread. LOL.

My issue: Keep getting this message in my File custom field description:

You have not defined a server path in the Upload Settings.

Although, it is defined correctly. Not sure what else it’s wanting.

       
Tyssen's avatar
Tyssen
756 posts
16 years ago
Tyssen's avatar Tyssen

Oh right, didn’t realise that the files were deleted from the server when you selected ‘remove’; I thought they were just removed from the entry. So that’s a double edit though isn’t it - first to remove the old one and then a second to upload the new one with the same name?

       
Matt Weinberg's avatar
Matt Weinberg
489 posts
16 years ago
Matt Weinberg's avatar Matt Weinberg
My issue: Keep getting this message in my File custom field description:

Have you seen this thread:

http://ellislab.com/forums/viewthread/87058/

So that’s a double edit though isn’t it - first to remove the old one and then a second to upload the new one with the same name?

When you mark a file to delete, a drop down comes down to let you upload a new file. The question will be, what happens first? If the deletion is done first, your upload will be golden. If the upload is done first, you may get an error. Only one way to find out.

       
First 39 40 41 42 43 Last

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.