ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Safecracker File and ImageSizer

April 08, 2011 6:22pm

Subscribe [4]
  • #1 / Apr 08, 2011 6:22pm

    FortySeven Media

    130 posts

    I’ve noticed when using the AJ Penninga image replacement method (with Matrix, ImageSizer and NSM Transplant) that when a file field is left blank, Safecracker file still sends a ‘.’ through to ImageSizer and thus ImageSizr chokes looking for a file and spitting out errors about “this format or extension not found/supported.”

    So basically when a page is created without an image it has all these PHP errors at the top of the page because ImageSizer is choking on it. I know there are a lot of other Addon’s involved here, but this worked fine with the EE file field and only after switching to Safecracker did this problem start happening. I’d like to see if this is reproducible before filing a bug.

    EE 2.1.3, latest versions of Safecracker, Matrix, NSM Transplant, Imgasizer)

  • #2 / Apr 11, 2011 2:48am

    John Henry Donovan

    12339 posts

    Jonathan,

    I tested this myself and using a combination of Safecracker File and Matrix produces this ‘.’
    Using Safecracker File on it’s own does not.

    The cell in the database is also empty

    I couldn’t file anything initially while looking through the code for Safecracker File.

    Could you go back and ask Brandon on this one as it sees, to only be the combination of both that causes this issue

  • #3 / Apr 11, 2011 12:22pm

    FortySeven Media

    130 posts

    Absolutely, I’ll check with him and let you know.

  • #4 / Apr 11, 2011 10:33pm

    Sue Crocker

    26054 posts

    Let us know what you find out.. We’ll be here.

  • #5 / Apr 17, 2011 7:53pm

    Erskine

    46 posts

    I don’t think this problem has anything to do with Matrix. I just ran into the same issue and tracked the period down to line 284 in ft.file.php

    $full_path = $file_info['path'].$file_info['filename'].'.'.$file_info['extension'];

    The problem is the file_info array is blank in our case so all that’s being outputted there is the period before the file extension.

  • #6 / Apr 17, 2011 11:46pm

    FortySeven Media

    130 posts

    Hey Jamie,

    So you’re saying this happens for you with the regular file field as well?

  • #7 / Apr 18, 2011 4:35am

    Erskine

    46 posts

    Hey Jon.

    No it doesn’t happen with the regular file. Only with safecracker file being used as a celltype. But the problem (I think) is with Safecracker File, not matrix.

    I’m no PHP developer but I amended the code slightly to get things working. I’m sure there’s a better way of doing it but at least it might point EllisLab support to the problem and help you in the short term.

    File: ft.safecracker_file.php
    Method: replace_tag()

    The problem seems to occur when the $file_info array exists but has empty values.

    Existing code:

    if ($file_info)
    {
        if ( ! is_array($file_info))
        {
            $file_info = parent::pre_process($file_info);
        }
        
        return parent::replace_tag($file_info, $params, $tagdata);
    }

    Change it to:

    if ($file_info)
    {
        if ( ! is_array($file_info))
        {
            $file_info = parent::pre_process($file_info);
        }
                
        $imploded_file_info = implode('', $file_info); 
                
        if (empty($imploded_file_info)) { 
            return '';
        } else { 
            return parent::replace_tag($file_info, $params, $tagdata);
        }
    
    }
  • #8 / Apr 18, 2011 5:58am

    John Henry Donovan

    12339 posts

    I went ahead and created a bug report here.

  • #9 / Apr 18, 2011 10:52am

    FortySeven Media

    130 posts

    Hey Jamie,

    Yeah that seems to take care of it for me. Thanks, man!

    And thanks for filing the bug John Henry 😉

  • #10 / Apr 19, 2011 2:20pm

    Sue Crocker

    26054 posts

    Hi, Jonathan,

    Glad you have a workaround. Since there’s a bug report for this, I’m going to go ahead and close the thread. Jonathan, if you comment on the bug report, you’ll be notified when the bug changes status.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases