Is wp_read_audio_metadata() function deprecated?

wp_read_audio_metadata() is not deprecated. It’s located in /wp-admin/includes/media.php, which is not loaded on the front end, hence the error your’re getting. You are using the function correctly. You can make wp_read_audio_metadata() available by including wp-admin/includes/media.php before calling the function, e.g.: require_once( ABSPATH . ‘wp-admin/includes/media.php’ ); $audio_file_path = get_attached_file( 1821 ); // example attachment ID var_dump( … Read more

Disable media library tab for non admins in uploader screen

This function will not show media library tab in upload screen function remove_medialibrary_tab($strings) { if ( !current_user_can( ‘administrator’ ) ) { unset($strings[“mediaLibraryTitle”]); return $strings; } else { return $strings; } } add_filter(‘media_view_strings’,’remove_medialibrary_tab’); I found out that switching to media library tab actually call this ajax action query-attachments. So i added another callback function to this … Read more

Modifying an uploaded image with ‘wp_get_image_editor’ and ‘wp_handle_upload_prefilter’

I decided to approach it differently. Instead of hooking into ‘wp_handle_upload_prefilter’ and tampering with the $file variable I decided to do the resize after the file is uploaded and after I get the attachment id like this: public function resize_attachment($attachment_id, $width, $height) { // Get file path $file = get_attached_file($attachment_id); // Get editor, resize and … Read more

Prevent large image uploads

You have a few different solutions available here: Automatically scaling down If you just do not want to store huge amounts of image data on your webspace, I’d recommend the Plugin Imsanity. This automatically scales down the uploaded images, even if they are too big. Forbid large uploads In this case the user has more … Read more

How to handle multiple instance of “send_to_editor” js function

only overwrite the send_to_editor function when your link or button is click but store the old function to restore it so try this on a click event: //store old send to editor function window.restore_send_to_editor = window.send_to_editor; //overwrite send to editor function window.send_to_editor = function(html) { var imgurl = jQuery(‘img’,html).attr(‘src’); current_item.siblings(‘.upload_image’).val(imgurl); current_item.parent().prepend(‘<div><img width=”300″ src=”‘+imgurl+'” alt=”banner image” … Read more

How to call WP3.5 Media Library manager?

From the article How to use WordPress 3.5 Media Uploader in Theme Options (by codestag.com), as seen in Using the WordPress 3.5 Media Uploader within plugins (by mikejolley.com). Mike Jolley’s article has quite some nice tricks. Important note: if the page where the uploader is going to be used doesn’t already have all media JS … Read more

How to upload image with simple form?

There are several parts. You need to add an enctype to the profile form. function edit_form_type_wpse_98375() { echo ‘ enctype=”multipart/form-data”‘; } add_action(‘user_edit_form_tag’,’edit_form_type_wpse_98375′); Then add a field to the form. function user_fields_wpse_98375($profileuser) { $_profile_photo = get_user_meta($profileuser->data->ID,’_profile_photo’,true); echo ‘<h3>’.__(‘Additional User Data’,THEME_TEXTDOMAIN).'</h3>’; echo ‘<tr class=”show-admin-bar”>’; echo ‘<th scope=”row”>’.__(‘Profile Photo’, THEME_TEXTDOMAIN).'</th>’; echo ‘<td’.$tspan.’>’; echo ‘<fieldset>’; echo ‘<legend class=”screen-reader-text”><span>’.__(‘Profile Photo’, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)