How can I get an image from the uploads dir and enter it in the media library? [closed]
How can I get an image from the uploads dir and enter it in the media library? [closed]
How can I get an image from the uploads dir and enter it in the media library? [closed]
The the_attachment_link returns an HTML link, so use this code: if ( $attachments = get_children( array( ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, ‘numberposts’ => 1, ‘post_status’ => null, ‘post_parent’ => $post->ID ) ) ); foreach ( $attachments as $attachment ) { echo wp_get_attachment_link( $attachment->ID, ” , true, false, ‘Link to image attachment’ ); } Here … Read more
You can find out the IDs of which images are included in a gallery by switching to the Text editor tab and look for a piece of code like this: The comma-separated list of image IDs are enclosed in the ids attribute If you’re looking to find out IDs of existing images in order to … Read more
WordPress has two different ways of displaying media. There’s the media overlay/modal view and also the list view, which is triggered by navigating to Admin > Media > Library then by clicking the list view icon next to the filter select box. To filter attachments in both locations, we will need to use two separate … Read more
You can make a query to loop through all the attachments, and then update the attachment info for each attachment in the while loop. Something like $args = array( ‘post_type’ => ‘attachments’, ‘post_status’ => ‘any’, ‘posts_per_page’ => -1, ) $query = new WP_Query($args) if($query->have_posts()): while($query->have_posts()): $query->the_post(); // 1. Get the attachment filename here and store … Read more
Now I have an answer for my own question.I solved this issue by using this code.I add this code just for sharing and helping other as it works for me. <input type=”file” name=”my_file_upload” id=”my_file_upload_id” class=”bg_checkbox” > function register_team_show_case_setting() { //register our settings register_setting(‘my_team_show_case_setting’, ‘my_file_upload’); } add_action(‘admin_init’, ‘register_team_show_case_setting’); Code to upload and save image: require_once( ABSPATH … Read more
Create an attachment template file within the theme. Since we are only interested in images, the file should be image.php <?php if ( have_posts() ) { the_post(); $image_url = wp_get_attachment_url(); } header(‘Location: ‘.$image_url); ?> Template Hierarchy
Your rule works with the attachment ID, so I’m not sure how you’re using the title, but the answer is almost identical in either case. The filter you want is attachment_link: function wpd_attachment_link( $link, $post_id ){ $post = get_post( $post_id ); return home_url( ‘/images/’ . $post->post_title ); } add_filter( ‘attachment_link’, ‘wpd_attachment_link’, 20, 2 ); Change … Read more
You’re on the right path with a rewrite rule. If you’re just delivering a file, you can hook an early action, check if a download was requested, then output the file and exit before WordPress ever gets to the stage of querying the database and deciding the request is a 404. // add the download … Read more
Untested but I am pretty sure this is the issue: You are trying to attach $uploadedfile to the email. You’ve set $uploadedfile to $_FILES[‘file’]. That is a very temporary file/file location. Once you use wp_handle_upload you want to be using $movefile instead. If you look at the Codex entry for that function you can see … Read more