Get attachment from post
You can use ACF(Advance Custom Filed) for this please read document for this https://www.advancedcustomfields.com/
You can use ACF(Advance Custom Filed) for this please read document for this https://www.advancedcustomfields.com/
On the Trac ticket you’ve linked at the bottom there is a solution to make it work function _save_attachment_url($post, $attachment) { if ( isset($attachment[‘url’]) ) update_post_meta( $post[‘ID’], ‘_wp_attachment_url’, esc_url_raw($attachment[‘url’]) ); return $post; } add_filter(‘attachment_fields_to_save’, ‘_save_attachment_url’, 10, 2); function _replace_attachment_url($form_fields, $post) { if ( isset($form_fields[‘url’][‘html’]) ) { $url = get_post_meta( $post->ID, ‘_wp_attachment_url’, true ); if ( … Read more
Good news for this old question, since WordPress 4.7, pdf’s thumbnail are automatically generated.
Use this in your theme’s functions.php: add_filter( ‘add_attachment’, ‘wpse_55801_attachment_author’ ); function wpse_55801_attachment_author( $attachment_ID ) { $attach = get_post( $attachment_ID ); $parent = get_post( $attach->post_parent ); $the_post = array(); $the_post[‘ID’] = $attachment_ID; $the_post[‘post_author’] = $parent->post_author; wp_update_post( $the_post ); }
@AboSami actually answered this question in an older post that was not showing up in my search diligence. While he was actually looking for something else his example code worked great. Here’s the script: <?php $post_id = $post->ID; if ( isset( $_POST[‘html-upload’] ) && !empty( $_FILES ) ) { require_once(ABSPATH . ‘wp-admin/includes/admin.php’); $id = media_handle_upload(‘async-upload’, … Read more
Place the code suggested below in functions.php of your desired theme, it worked for me with WP 3.4: http://matty.co.za/2009/11/custom-url-rewrites-in-wordpress/
You cannot do that with pure PHP. The table is created in wp-admin/includes/ajax-actions.php::wp_ajax_find_posts(), and there is no filter. But look at the radio buttons: name=”found_post_id” value=”‘ . esc_attr($post->ID) You can print a script on the action admin_footer-upload.php that extracts the post ID from the values and adds a new column to the table. Here is … Read more
These options are hardcoded into the tmpl-attachment-display-settings Underscore media template in the /wp-includes/media-template file: <script type=”text/html” id=”tmpl-attachment-display-settings”> <h3><?php _e(‘Attachment Display Settings’); ?></h3> …cut… <select class=”link-to” data-setting=”link” <# if ( data.userSettings && ! data.model.canEmbed ) { #> data-user-setting=”urlbutton” <# } #>> <# if ( data.model.canEmbed ) { #> <option value=”embed” selected> <?php esc_attr_e(‘Embed Media Player’); ?> … Read more
Here is a tutorial that shows how to add custom fields to the attachments/media gallery/thickbox/iframe/whatever-you-call it overlay. I’ve successfully used it, but have not yet taken it much further by adding radio buttons/checkboxes/etc or messed with limiting the changes to particular post types, but that all looks completely doable too. Here is the code from … Read more
This is untested, so apologies there, but I’m thinking out loud, have you tried re-registering the post type afterwards? Or flushed rewrite rules after your initial attempt with flush_rewrite_rules();? function change_attachment_post_type() { $args = get_post_type_object(‘attachment’); $args->has_archive = true; $args->rewrite = [ ‘slug’ => ‘media’ ]; register_post_type($args->name, $args); // As a temporary one time, remove after … Read more