• One of my WordPress clients relies heavily on the Media Vault plugin for their membership website. In the years since installing this plugin, the support has died off and it has received the dreaded “This plugin hasn’t been updated in over 2 years” message.

    It’s still a great plugin, and having looked over a good portion of the code, I think it’s very-well written. Whether the original developer didn’t have enough time or didn’t think enough people used their plugin, I still think Media Vault is worth maintaining and still using. Hopefully the community can restart Media Vault, much like they did with Postman SMTP becoming Post SMTP.

    While using this plugin on PDFs and Word document files, I received the following error message. The wp_get_attachment_metadata was not returning the file URL or any information for that matter.

    PHP Warning: Illegal string offset ‘sizes’

    To fix, I incorporated the following code to the /wp-content/plugins/media-vault/includes/mgjp-functions.php file:

    COMMENT OUT THIS LINE:
    // $meta = wp_get_attachment_metadata( $attachment_id );

    USE THIS FUNCTION INSTEAD:
    $meta = array();
    $meta[‘file’] = get_attached_file($attachment_id);
    $meta[‘sizes’] = ”;

    Several topics have also mentioned that files can still be accessed with this plugin. To resolve this, I wrote a custom download script that checks the permissions of the page the file was uploaded to in order to double check the logged-in user has enough permission to retrieve the file. To redirect to that download script, I have added this in the .htaccess file:

    # Don’t redirect images
    RewriteRule ^wp-content/uploads/(.*)\.jpg$ – [R=301,L]
    RewriteRule ^wp-content/uploads/(.*)\.png$ – [R=301,L]
    RewriteRule ^wp-content/uploads/(.*)\.gif$ – [R=301,L]

    # Redirect to check for permissions
    RewriteRule ^wp-content/uploads/(.*)$ /wp-content/themes/mytheme/download\.php?file=$1 [R=301,L,QSA]

    In the future, I may also post the download script in the hope that it encourages the original developer to pickup the project or perhaps pass it onto somebody who will.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Running on WordPress v4.9.1 and PHP v7’ is closed to new replies.