• Resolved frenchomatic

    (@frenchomatic)


    In my system I also upload some special file types .slave with MIME type application/zip. The plugin however seems to renaming my .slave files to .zip . This creates issues as the files are then downloaded by clients for reprogramming motors. They need to remain as .slave extensions. It seems and edit to the alias.php file solves it

    ‘slave’=>array(
    ‘application/zip’,
    ),

    I presume this is the correct way to proceed?

    • This topic was modified 5 months, 1 week ago by frenchomatic.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Blobfolio

    (@blobfolio)

    There are two different ways you can fix this (without manually patching the plugin):

    OPTION ONE:

    If .slave files are always zips, the simplest solution is to update your upload_mimes filter hook to use the appropriate ext/type pairing, i.e. $existing_mimes['slave'] = 'application/zip'; (rather than application/octet-stream).

    OPTION TWO:

    If you want/need to keep the files associated with application/octet-stream in the backend, you can hook into lotf_get_mime_aliases to programmatically expand the alias list used by Lord of the Files.

    (This is equivalent to manually patching aliases.php, but saves you the trouble of having to repatch that file every time a new version of the plugin is released.)

    function my_custom_mime_aliases ( $mimes, $ext ) {
    if ('slave' === $ext) {
    // $mimes should already have 'application/octet-stream' since
    // it inherits types known to WP (including custom upload_mimes
    // types), so you just need to add the ZIP type:
    $mimes[] = 'application/zip';
    }

    return $mimes;
    }
    add_filter( 'lotf_get_mime_aliases', 'my_custom_mime_aliases', 10, 2 );

    Please let me know if either work out for you! I’ll leave the ticket open in the meantime just in case.

    Thread Starter frenchomatic

    (@frenchomatic)

    Silly me – I had it set to the wrong mime type and should have been $existing_mimes[‘slave’] = ‘application/zip’;

    The second method is interesting if I end up needing to add different mime types to a file extension.

    Many thanks for your help and I am sure this post will help others too.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.