Thanks, Slapshotw. I’ve actually tried Resize Images set to both Auto and Anchor Width - both ways still resize smaller image up. It works perfect for images larger than the max settings. So, basically, it resizes all images to the max setting no matter if they are smaller or larger.
And I also have Delete from Server set to Yes. It deletes the file fine when I do it through the Edit tab, but if I just delete the entire entry, it won’t delete the file.
Those are two options you need to look for. Check out the documentation here: http://docs.markhuot.com/ee/extensions/file The first question requires you to change the “Resize Images” setting–you probably want to use “Auto.” The second question is to set “delete from server” to “yes.” Some people aren’t seeing those options on their EE installs in the file upload preferences after installing the extension. Are you included in that?
Ah - guess that explains the no deleting of the file. Thanks peschehimself.
I was able to hack the extension to fix the resizing problem. I’m not a PHP expert, though, so if anyone sees anything glaringly wrong here, please let me know.
First, you need to change this (around line 940):
$resize = $this->resize_images;
if($this->resize_images == 'auto' && $file_field['max_width'] != '' && $file_field['max_height'] != '')
{
$src_proportion = $src_width/$src_height;
$dst_proportion = $dst_width/$dst_height;
if($src_proportion > $dst_proportion)
{
$resize = 'anchor_width';
}
else
{
$resize = 'anchor_height';
}
}
to this:
$resize = $this->resize_images;
if($this->resize_images == 'auto' && $file_field['max_width'] != '' && $file_field['max_height'] != '')
{
$src_proportion = $src_width/$src_height;
$dst_proportion = $dst_width/$dst_height;
if($src_height > $dst_height)
{
$resize = 'anchor_height';
}
else if($src_width > $dst_width)
{
$resize = 'anchor_width';
}
else
{
$resize = 'NULL';
}
}
and then around line 994 change this:
// =============================================
// Stretch Images, Happens By Default!
// =============================================
else
{
}
to this:
// =============================================
// Will leave image alone by default
// =============================================
else
{
$dst_width = $src_width;
$dst_height = $src_height;
}
It’ll no longer stretch the image by default, but I can’t imagine why you’d want that anyway.
Hi Guys
Back again with a small bug i just found. When editing entries that don’t have file upload fields, the function “uploadFiles” is still called on the form submit (e.g. Quick Save), so we need to check whether the function exists (it exists if there are any file upload fields and it is included) or not:
// =============================================
// Make Publish Table multipart/form-data
// =============================================
if(preg_match("/name=.entryform./", $out, $matches))
{
$out = str_replace($matches[0], $matches[0]." enctype=\"multipart/form-data\" onsubmit=\"return uploadFiles();\"", $out);
}
Needs to be:
// =============================================
// Make Publish Table multipart/form-data
// =============================================
if(preg_match("/name=.entryform./", $out, $matches))
{
$out = str_replace($matches[0], $matches[0]." enctype=\"multipart/form-data\" onsubmit=\"if(typeof uploadFiles == 'function') { return uploadFiles() };\"", $out);
}
Most of you won’t notice this bug, but we’re using Firebug quite often so it yields a javascript error that blocks the whole saving process every time a form without file upload fields is submitted in the edit entry area.
Hmm, pursuant to my earlier post (images not resizing), the following fields don’t seem to work either:
I’ve tried with and without the pair of matching braces, in every combination I can think of. Also had a quick squiz through the code but couldn’t find anything obviously associated with outputting those fields (but that doesn’t mean anything!).
I just tried uploading a pdf with spaces in the filename. I thought that the ‘clean file names’ regex would have cleaned this file name.
$file_names[$file_key] = preg_replace(array('/(?:^[^a-zA-Z0-9_-]+|[^a-zA-Z0-9_-]+$)/', '/\s+/', '/[^a-zA-Z0-9_-]+/'), array('', '_', ''), $file['name']).$file['ext'];
The ‘/\s+/’ bit of the regex should be changing spaces to ” (ie removing) but it doesnt seem to be happening… Or it does, but the new file name isnt what gets entered into the database.
Does anyone have any clues as to why this is happening?
Mark:
Thanks again for writing such a beautiful extension. I really appreciate that you repaired the file upload preferences bug.
I have a suggestion. When a person needs to include photos in a blog entry (like a text area) they sometimes need to include images.
Would it be possible to have your file extension display the final url of the photo/file it just uploaded? You have the thumbnail displayed, I was thinking that displaying the url to the uploaded image/file would allow the user to copy the url and paste it into their text.
Has anyone come up with a way to associate a comment with each photo that is uploaded? I’m looking to use Moo.Tools or JQuery to display a group of uploaded images with that played out “Lightbox” effect. Just wondering if anyone has tinkered with this module to permit a comment to be entered for each photo, if not, I’ll be beginning work on this so if anyone has similar needs, feel free to PM me.
Has anyone come up with a way to associate a comment with each photo that is uploaded?
I used a kludgy method here: http://ellislab.com/forums/viewthread/38997/P342/#335189
The idea is that you make a custom field with each comment on a different line, and use php to make each line an array element. The other idea, suggested after mine, is to use Mark Huot’s Multi-Text extension to make them and put each element of that into an array. Once it’s in an array, you should be able to associate them with the pictures in a lightbox pretty easily.
Xopher, I may have misunderstood you, but if all your wanting is a comment to be associated with a photo, why not just create another custom field for the comment?
So you have custom field ‘photo_1’ and custom field ‘photo_1_comment’.
The user uploads the photo using the first custom field, then writes the comment in the second custom field.
Repeat custom fields for as many photos as required.
Of course, this is only practicable for a few photos. A much easier way would be to use the official photo gallery module.
@Adam You did misunderstand. ;-) I’m talking about multiple images for a given post. So a single comment field wouldn’t suffice.
@slapshotw This is a nice hack, but I agree it is kludgy and maybe not the kind of thing I want to explain to clients. If it were I who were going to be doing the updating, this would be a totally reasonable solution though, so I suggest others take a look at the link provided. I’m going to investigate the Mult-Text extension and see if there are possibilities there. I will post back with any new info on the topic.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.