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

adam11238's avatar
adam11238
34 posts
17 years ago
adam11238's avatar adam11238

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?
       
gridonic's avatar
gridonic
231 posts
17 years ago
gridonic's avatar gridonic

Seems that deleting entries does not delete the associated files, but this seems to be the case with default image uploads through EE too.

Is there a hook for modules / extensions that’s being triggered when deleting entries?

       
adam11238's avatar
adam11238
34 posts
17 years ago
adam11238's avatar adam11238

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.

       
John Macpherson's avatar
John Macpherson
113 posts
17 years ago
John Macpherson's avatar John Macpherson

Adam…

Cant thank you enough for that fix!

I now have thumbs working, just need to set up my litebox now. :coolsmile:

       
iain's avatar
iain
317 posts
17 years ago
iain's avatar iain

wow… 28 page thread, I feel a “official” file uploader field coming on….

       
gridonic's avatar
gridonic
231 posts
17 years ago
gridonic's avatar gridonic

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.

       
Adam George's avatar
Adam George
283 posts
17 years ago
Adam George's avatar Adam George

Happy birthday Mark for the 25th! You are so not old!!

       
Adam George's avatar
Adam George
283 posts
17 years ago
Adam George's avatar Adam George

Hmm, pursuant to my earlier post (images not resizing), the following fields don’t seem to work either:

file_url — URL to the uploaded file.

file_thumb_url

file_thumb_path (as per example on marks docs page)

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!).

       
vinci's avatar
vinci
85 posts
17 years ago
vinci's avatar vinci

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?

       
Eric Snyder's avatar
Eric Snyder
202 posts
17 years ago
Eric Snyder's avatar Eric Snyder

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.

       
Steven SE's avatar
Steven SE
8 posts
17 years ago
Steven SE's avatar Steven SE

Hi,

Is it possible to first resize and then crop the image? So 2 actions in one upload. When I upload an image with a resolution of 3000+ I get a very little piece of the full image.

       
xopher's avatar
xopher
12 posts
17 years ago
xopher's avatar xopher

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.

       
Matt Weinberg's avatar
Matt Weinberg
489 posts
17 years ago
Matt Weinberg's avatar Matt Weinberg
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.

       
Adam George's avatar
Adam George
283 posts
17 years ago
Adam George's avatar Adam George

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.

       
xopher's avatar
xopher
12 posts
17 years ago
xopher's avatar xopher

@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.

       
First 32 33 34 35 36 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.