How to add year and month path to old attachment images?

If you want to change the post thumbnail URL, use the filter wp_get_attachment_url; Try to follow the next code: // NAV: Change the url for thumbnail for post function wpcoder_change_post_thumbnail_url($url, $post_id) { if (strpos($url, ‘img/uploads/’) !== false) { $year = date(‘Y’); // Year folder $month = date(‘m’); // Month folder $url = str_replace(“img/uploads/”, “app/uploads/’.$year.”https://wordpress.stackexchange.com/”.$month.’/”, $url); … Read more

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)