How to insert information about the size and type of an attachment into page
How to insert information about the size and type of an attachment into page
How to insert information about the size and type of an attachment into page
There has been a misunderstanding of how page content works here: but this code not modified links in page content. What is wrong with this code? Once the links are saved in the post content you have to reopen the post and resave/reinsert for new code to take effect. Filters only modify the links when … Read more
Try code below. <?php $attachments = array(); array_push($attachments, WP_CONTENT_DIR . ‘/uploads/my-first-attachment.docx’ ); array_push($attachments, WP_CONTENT_DIR . ‘/uploads/my-second-attachment.zip’ ); $to=”[email protected]”; $subject=”Online: multiple attachment demo through wp_mail of wordpress”; $message=”This is testing”; $headers=”From: NAPSWI online <[email protected]>”; get_header(); if( wp_mail( $to, $subject, $message, $headers, $attachments) ) { // the message was sent… echo ‘The test message was sent. Check … Read more
Using wp_mail to send attachment from a file stream content
modify the_content() for page to display attachments with own style
you can use within your page or post template and also replace $attachment_id with the ID of the attachment you want to display information for. // Assuming $attachment_id contains the ID of the attachment $attachment_metadata = wp_get_attachment_metadata($attachment_id); if ($attachment_metadata) { // Get file size in bytes $file_size = filesize(get_attached_file($attachment_id)); // Convert file size to human-readable … Read more
You don’t need to know the file names before, you’ll have access to them. I saw you using $subject = $_POST[‘subject’]; – this means the subject will be the value of the input with the name of “subject”. In your case, this one : <input id=”subject” class=”form-control” name=”subject” type=”text” /></div> We can use the same … Read more
I think what you need is media_upload_{$type} hook. Here’s the documentation for it: https://developer.wordpress.org/reference/hooks/media_upload_type/ There’s also an easier way to achieve a similar result, by using the filter wp_handle_upload which is really straightforward. Here’s the doc about it: https://developer.wordpress.org/reference/hooks/wp_handle_upload/ If you could provide more details about the result you want to achieve, I’ll try my … Read more
The WordPress function next_image_link() do accept a second parameter $text which will show up instead of a thumbnail image. Example – <?php next_image_link( false, ‘Next Image’ ); ?>
That is the attachment’s data in serialized format. There’s an explanation of the data in the wp_get_attachment_metadata codex entry. If you have some custom function doing image uploading, you can use wp_generate_attachment_metadata to generate that data.