[wp-trac] [WordPress Trac] #47049: Unzip_file causing Media file upload error
WordPress Trac
noreply at wordpress.org
Sun Apr 28 17:10:43 UTC 2019
#47049: Unzip_file causing Media file upload error
---------------------------+------------------------------
Reporter: troytempleman | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Upload | Version: 5.1.1
Severity: normal | Resolution:
Keywords: | Focuses:
---------------------------+------------------------------
Comment (by troytempleman):
I tried the add_attachment hook below and the good news it works with no
media upload errors, but the bad news this happens on every media upload,
not just the icon fonts.
{{{
function unzip_icon_fonts( $post_ID ){
$file_path = get_attached_file( $post_ID );
require_once(ABSPATH . 'wp-admin/includes/file.php');
WP_Filesystem();
$destination = wp_upload_dir();
$destination_path = $destination['path'];
$unzipfile = unzip_file($file_path, $destination_path);
}
add_action( 'add_attachment', 'unzip_icon_fonts' );
}}}
So, I tried restricting it to the icon fonts:
{{{
function unzip_icon_fonts( $post_ID ){
if ( $post_ID == get_theme_mod('icon_fonts', '') ) {
$file_path = get_attached_file( $post_ID );
require_once(ABSPATH . 'wp-admin/includes/file.php');
WP_Filesystem();
$destination = wp_upload_dir();
$destination_path = $destination['path'];
$unzipfile = unzip_file($file_path, $destination_path);
}
}
add_action( 'add_attachment', 'unzip_icon_fonts' );
}}}
However, this doesn't work at all. Am I missing something?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47049#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list