wp_generate_attachment_metadata for non-images files

wp_generate_metatadata() should create metadata for image, video, and audio file types. There is and if/elseif conditional in the source that limits the function to those three. However, the last line is: return apply_filters( ‘wp_generate_attachment_metadata’, $metadata, $attachment_id ); So you could use the wp_generate_attachment_metadata filter to generate the metadata you want. There are plenty of answers … Read more

limit media upload to once a day

You will need to create a meta field for users identifying that user when he already uploaded something in that day (or in the last 24 hours). After you do that, you will need to create a function to trigger in some upload action, like wp_handle_upload_prefilter or wp_handle_upload to check if user can upload something … Read more

Dynamically determine the width and height of a image file to be cropped & uploaded AFTER form submission given fixed aspect ratio

Here is my resolution: Download and unzip JCrop and unzip jquery.Jcrop.min.js & jquery.Jcrop.css to the js & css sub-directory respectively under the theme template directory. Place the following code in header.php just before </head> (you need to comment out the first line if you’ve already include the jquery.min.js in the other place): <script src=”https://wordpress.stackexchange.com/questions/209358/<?php echo … Read more

Media Upload not working after hiding some elements from functions.php

Replace your code with this code:- add_action(‘wp_footer’, ‘myCssCode’, PHP_INT_MAX); function myCssCode() { ?> <style> #toplevel_page_wpcf7, #wp-admin-bar-wp-logo, #screen-meta-links, #menu-tools, #wp-admin-bar-wpseo-menu, #footer-upgrade, #toplevel_page_wpfront-user-role-editor-all-roles, #toplevel_page_vc-general, #menu-settings, #toplevel_page_wpseo_dashboard, #toplevel_page_revslider, #toplevel_page_themepunch-google-fonts, #menu-appearance, #wp-admin-bar-snap-post, .error { display:none; } </style> <?php }

Get URL of Featured Image After wp_insert_post()

Well you have the ID as $attach_id so you can use a function such as wp_get_attachment_url() where you can pass $attach_id and get a url returned: $featured_url = wp_get_attachment_url( $attach_id ); Or if you want more information such as width, height, etc. you can use functions like wp_get_attachment_image_src() or wp_get_attachment_metadata().