media file uploading

jQuery(document).ready(function($){ $(‘#txt_image’).click (function(e){ e.preventDefault(); var image = wp.media({ title:”Upload Image”, multiple:false }).open().on(“select”, function(e){ var uploaded_image = image.state().get(“selection”).first(); var image_data = uploaded_image.toJSON(); jQuery(“#getImage”).attr(“src”, image_data.url); jQuery(“#student_image”).val(image_data.url); }); }); });

413 Request Entity Too Large nginx/1.18.0 (Ubuntu)

Problem Solved In addition to increasing the maximum size in nginx.conf, php.ini and wp-conf.php files, it was necessary to raise the limit in the nginx server block for the site. I increased the default value of client_max_body_size 2M; to client_max_body_size 200M; and now all uploads go smoothly and quickly. Hopefully, someone can tell me why … Read more

MIME types not recognized by media library

I was able to update the mime types via MySQL — here’s the update query I used: UPDATE `wp_posts` SET `post_mime_type` = ‘audio/mpeg’ WHERE `post_name` LIKE ‘%mp3%’ AND `post_mime_type` != ‘audio/mpeg’ Setting this also made the correct metadata for the files appear, and the offload plugin worked as expected. HURRAY

Get uploaded video URL

To get the URL of a video attachment (like an MP4 file), you should use wp_get_attachment_url() and not wp_get_attachment_link() because the latter returns an HTML for an anchor linking to the attachment page or the attachment file itself: $video_url = wp_get_attachment_url( $attachment_ID ); // Sample output: https://example.com/wp-content/uploads/2020/11/video.mp4 $att_page = wp_get_attachment_link( $attachment_ID, ‘full’, true ); // … Read more