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.
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?
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: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.{if imageUpload != ""}{imageUpload}{file_thumb_url}{/imageUpload}{/if}
Good to know! Thanks for the heads up and info. 😉
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.
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!
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?
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
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
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).
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
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.
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.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.