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

New Extension: nGen File Field for FieldFrame

Development and Programming

Mark Bowen's avatar
Mark Bowen
12,637 posts
15 years ago
Mark Bowen's avatar Mark Bowen
yeah it worked fine when there were only a few videos, but now he has about 30 videos up there and it is slow. I have no idea what it could be or how to debug it.

Still seems a little odd as you mentioned in the Tech Support post that it only did this in one of the entries and not the others. Is that correct?

If you create a new post in that weblog do you still have the problem or not?

       
danshields's avatar
danshields
15 posts
15 years ago
danshields's avatar danshields

you can create a new post and edit one, it just takes about 10 - 15 minutes for that page to load to do so. Its the actual loading of the edit or post new entry page. Sorry it wasn’t one of the entries, its just the one weblog. I use the ngen file upload for other things in other weblogs but for the videos weblog trying to edit any of the entries or posting a new one is the problem.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
15 years ago
Mark Bowen's avatar Mark Bowen
Sorry it wasn’t one of the entries, its just the one weblog.

Ah right, that makes more sense now. When you had said just the one page I thought that was a little odd and might be something else at play but if it’s the whole weblog then that makes a bit more sense. Unfortunately doesn’t help fix things for you yet but hopefully Fred or someone else in this thread might have an idea as to why this is happening.

If I come across anything else myself though then I’ll be sure to let you know.

Best wishes,

Mark

       
Fred Boyle's avatar
Fred Boyle
73 posts
15 years ago
Fred Boyle's avatar Fred Boyle

NOTE: Due to the size of this thread please private message me with any issues you would like to bring to my attention. I am not receiving notifications and keeping up with this thread has become very difficult. You can also reach me on Twitter (@fredboyle). Thanks!

Also we are aware of the memory issues that some of you are encountering and have solutions to reduce memory usage currently in beta testing. We hope to have a new release out in the next several weeks.

       
danshields's avatar
danshields
15 posts
15 years ago
danshields's avatar danshields

So I found that with an flv the check to see if it is an image and then create a thumbnail starts acting really weird so I found if I put the following in ft.ngen_file_field.php around line 790 made my problem go away.

function _is_image($file) {
        
  
        /////Added by Dan Shields
        if (substr(strrchr($file, '.'), 1) === 'flv'){
            return false;
        }
        //////////////////////
        
        
        
        $is_image = false;
        // legacy for MH File compatibility
        $file = trim($file);
            
        switch( exif_imagetype($file) ) {
            case IMAGETYPE_GIF:
            case IMAGETYPE_BMP:
            case IMAGETYPE_JPEG:
            case IMAGETYPE_PNG:
                $is_image = true;
                break;
        }
        return $is_image;
    }
       
Andrew Macpherson's avatar
Andrew Macpherson
38 posts
15 years ago
Andrew Macpherson's avatar Andrew Macpherson

Does anyone know if nGen FF can work with MSM weblogs or fields that have the same name? I have an installation where an nGen FF image will not show up in another MSM site.

The situation is that I am currently developing two sites for a publishing company: the smaller one is a special imprint of the larger one, so it puts out only a few books, all of which also appear in the website for the parent company.

The weblog structure for both sites is basically the same, because I would prefer to keep the weblog and field names the same in both sites, for ease of maintenance. That works successfully for every single field I have so far used … except for the nGen FF ones.

Just to give you a bit of background, what I have is essentially something like this:

{exp:weblog:entries site=“parent|child” weblog=“catalog” status=“open|published|forthcoming”} {cover} <—the nGen File field {title} {description} … etc … {/exp:entries}

If {cover} is a stock-standard EE text file with a stock-standard EE image reference, there’s no problem—except for the fact that the end users seem to find the stock-standard EE procedure for uploading images too confusing, and have trouble getting the image in the right place. That’s exactly where nGen FF really shines, but obviously it’s a real problem if I can’t display the images!

I have to admit that I don’t have a lot of experience with EE yet, so it could be that I am simply going about things in a less than ideal way. Or is it just that the approach is reasonably sound, but that nGen is the one element that cannot deliver in this situation. (As I said, every other field type I have used so far seems to operate correctly across sites.)

If anyone can help me out with this issue, I’d really appreciate it!

       
Fred Boyle's avatar
Fred Boyle
73 posts
15 years ago
Fred Boyle's avatar Fred Boyle

Shhh… v1.0 has been released. Find it at http://www.ngenworks.com/software/ee/ngen-file-field/.

SUPPORT: Can now be found at http://help.ngenworks.com.

NOTE: We are no longer actively monitoring this thread, please contact us via our new support area, via Twitter or PM.

       
Paul Cripps (Nine Four)'s avatar
Paul Cripps (Nine Four)
104 posts
15 years ago
Paul Cripps (Nine Four)'s avatar Paul Cripps (Nine Four)

Here’s a weird on when ngen-file-field is installed alongside LG twitter then add row link is vanished.

So I dis-enabled LG twitter and it works fine!

       
RealityDesign's avatar
RealityDesign
70 posts
15 years ago
RealityDesign's avatar RealityDesign

Is there documentation somewhere about how to get this to work in an SAEF? I can’t get it working. The files upload fine, but if you go “edit” in the CP, the files don’t show up. They’re physically on the server, in the right folder, and renamed if they had a duplicate name, but the custom field is empty.

       
RealityDesign's avatar
RealityDesign
70 posts
15 years ago
RealityDesign's avatar RealityDesign

OK, according to ngen, this is a known issue for v1.0. So then, how the hell do I get v0.9.10??? All you can download is 1.0, but it doesn’t work with an SAEF. Am I the only one that finds this kind of strange? They broke a key component of the extension, then called it “1.0?”

       
RealityDesign's avatar
RealityDesign
70 posts
15 years ago
RealityDesign's avatar RealityDesign

Well, I got lucky and figured I’d try to just change the number in the zip file URL and it worked…

Changed: http://www.ngenworks.com/software/ee/ngen-file-field/ngen-file-field-1.0.zip

To: http://www.ngenworks.com/software/ee/ngen-file-field/ngen-file-field-0.9.10.zip

I guess for the time being, if you’re having SAEF issues, use the second link I just posted.

       
RealityDesign's avatar
RealityDesign
70 posts
15 years ago
RealityDesign's avatar RealityDesign

I’m not sure how many of you would want this, but I basically had to customize this extension for my needs. I was originally trying to get some help from nGen, but they didn’t seem too interested in even talking to me and just told me to subit a feature request. Needless to say, when you need something NOW, you don’t submit feature requests, you go make features yourself.

So, what I have working now is nGen file field creating unique sub-folders for each author. So, if your author ID is say 123, instead of files being uploaded to images/uploads/, they get uploaded to images/uploads/123/. This was critically important as the site I’m doing this for will have tens of thousands of “authors” (users) that each need to upload about 10 images. Having all of the images all in one folder would be a bad idea, obviously, so I came up with this. Now I just need to modify what I have a touch so instead of /123, it gets exploded and put together as /1/2/3. With 10,000 users, having 10,000 folders in one place would almost be as bad as all of the images in one folder, so I think doing the sub folders for each digit will be the best way around that.

Anyway, if this is something you’re interested in, let me know and I’ll post the code. I have it working with an SAEF and the CP.

       
Todd D.'s avatar
Todd D.
460 posts
15 years ago
Todd D.'s avatar Todd D.
Anyway, if this is something you’re interested in, let me know and I’ll post the code. I have it working with an SAEF and the CP.

Curious to see how you worked it out.

       
RealityDesign's avatar
RealityDesign
70 posts
15 years ago
RealityDesign's avatar RealityDesign

In the most simple terms, this is basically all I changed:

//
    // Retrieves the upload preferences for an upload location
    // returns upload_prefs array
    //
    function _get_upload_prefs($u_id) {
        
        if( !isset($this->upload_prefs['loc_id']) || $this->upload_prefs['loc_id'] != $u_id ) {
            global $DB, $FNS, $PREFS;
            
            $query = $DB->query("SELECT * FROM " . $this->db_prefix . "_upload_prefs WHERE id = $u_id");
            
            if (isset($_POST['author_id'])) {
                $author_id = $_POST['author_id'];    
            } else if (isset($_GET['entry_id'])) {
                $entry_id = $_GET['entry_id'];
                $author_query = $DB->query("SELECT * FROM " . $this->db_prefix . "_weblog_titles WHERE entry_id = $entry_id");
                $author_id = $author_query->row['author_id'];
            } else {
                $author_id = "none";
            }
            
            $this->upload_prefs['loc_id'] = $u_id;
            $this->upload_prefs['server_path'] = $query->row['server_path'] . $author_id . "/";
            $this->upload_prefs['server_uri'] = parse_url($query->row['url'], PHP_URL_PATH) . $author_id . "/";
            //$upload_prefs['server_url'] = $FNS->remove_double_slashes( $PREFS->ini('site_url') . $upload_prefs['server_uri'] );
            $this->upload_prefs['server_url'] = $query->row['url'] . $author_id . "/";
            $this->upload_prefs['allowed_types'] = $query->row['allowed_types'];
            $this->upload_prefs['max_file_size'] = $query->row['max_size'];
        }
            
        //return $upload_prefs;
    }

Now, there were some other minor issues, such as getting nGen to create new folders on publish, not just edit, and I fixed those as well. For whatever reason, if a folder doesn’t exist when using the Edit CP, nGen makes a new folder you, but this function never gets executed from the publish CP. Now I have that working on both.

If you want the whole file, just send me a PM.

       
RealityDesign's avatar
RealityDesign
70 posts
15 years ago
RealityDesign's avatar RealityDesign

I have the “exploded” version working now, where it makes sub-folders 6 digits deep. So for example, a user ID of 123456 would have images located at: images/uploads/1/2/3/4/5/6/filename.jpg. User ID 1 would be located at: images/uploads/0/0/0/0/0/1/filename.jpg.

This is the code:

//
    // Retrieves the upload preferences for an upload location
    // returns upload_prefs array
    //
    function _get_upload_prefs($u_id) {
        
        if( !isset($this->upload_prefs['loc_id']) || $this->upload_prefs['loc_id'] != $u_id ) {
            global $DB, $FNS, $PREFS;
            
            $query = $DB->query("SELECT * FROM " . $this->db_prefix . "_upload_prefs WHERE id = $u_id");
        
            if (isset($_POST['author_id'])) { // if this is a new entry, get the author id from the hidden form field
                $author_id = $_POST['author_id'];    
            } else if (isset($_GET['entry_id'])) { // if this is an existing entry, get the entry ID and find the author
                $entry_id = $_GET['entry_id'];
                $author_query = $DB->query("SELECT * FROM " . $this->db_prefix . "_weblog_titles WHERE entry_id = $entry_id");
                $author_id = $author_query->row['author_id'];
            } else { // if all else fails, give it a 0 value so there aren't any "undefined" notices
                $author_id = "0";
            }

            $auth = $author_id . ""; // get the author id and convert it to a string
            $length = strlen($auth); // get the number of digits of the id
            
            if ($length == 1) {
                $author = "0/0/0/0/0/" . $auth[0] . "/";
            } else if ($length == 2) {
                $author = "0/0/0/0/" . $auth[0] . "/" . $auth[1] . "/";    
            } else if ($length == 3) {
                $author = "0/0/0/" . $auth[0] . "/" . $auth[1] . "/" . $auth[2] . "/";    
            } else if ($length  == 4) {
                $author = "0/0/" . $auth[0] . "/" . $auth[1] . "/" . $auth[2] . "/" . $auth[3] . "/";    
            } else if ($length == 5) {
                $author = "0/" . $auth[0] . "/" . $auth[1] . "/" . $auth[2] . "/" . $auth[3] . "/" . $auth[4] . "/";    
            } else if ($length == 6) {
                $author = $auth[0] . "/" . $auth[1] . "/" . $auth[2] . "/" . $auth[3] . "/" . $auth[4] . "/" . $auth[5] . "/";    
            }
                    
            $this->upload_prefs['loc_id'] = $u_id;
            $this->upload_prefs['server_path'] = $query->row['server_path'] . $author;
            $this->upload_prefs['server_uri'] = parse_url($query->row['url'], PHP_URL_PATH) . $author;
            //$upload_prefs['server_url'] = $FNS->remove_double_slashes( $PREFS->ini('site_url') . $upload_prefs['server_uri'] );
            $this->upload_prefs['server_url'] = $query->row['url'] . $author;
            $this->upload_prefs['allowed_types'] = $query->row['allowed_types'];
            $this->upload_prefs['max_file_size'] = $query->row['max_size'];
        }
            
        //return $upload_prefs;
    }
    //[/code]

Then all you have to do is find the two places with the "mkdir" function, and add "true" to the end of it to make the mkdir recursive.

Change:
[code]$create_dir = mkdir($path, 0777);

To:

$create_dir = mkdir($path, 0777, true);
       
First 38 39 40 41

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.