Define how an attached image is rendered

To replace <img> tags with <picture> tags in the content of your posts, follow these steps: Add a filter for post content: This filter will modify the post content to replace <img> tags with <picture> tags, allowing for responsive images based on screen size and resolution. Implement the replacement function: The function replace_content_images_with_picture_tags will find … Read more

Get Specific Files (Only Specific Extension Type All Files in Loop ) from Media

You don’t need to use strpos() to figure out the extension because you’ve already parsed the URL above and stored the extension in $AllAtachmentURLextension, so all you need to do is //for Specific Extensions if( ‘docx’ == $AllAttachmentURLextension ) { // docx handling here } elseif ( ‘pdf’ == $AllAttachmentURLextension ) { // pdf handling … Read more

Get field added via attachment_fields_to_edit filter in Gutenberg

Yes, you’re right that the slimImageObject function is the reason why you’re seeing/getting only those limited list of props. But don’t worry, you can use wp.data.select( ‘core’ ).getMedia( <attachment id> ) to get the attribution meta (and any other meta or props in the full attachment object). Here’s an example that worked for me: items.map((item, … Read more

Display file size and type on page or post with attachments

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

wp_mail attachment not working in wordpress

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