How to skip the creation of landscape thumbnails for an original portrait image

You were headed in the right direction. There is another filter out there that handles intermediate_image_sizes_advanced. You can add or remove custom sized thumbnails in there. Rather than NOT creating your landscape custom sizes on a Portrait upload, maybe try to only create the landscape custom sizes on a landscape upload. add_filter( ‘intermediate_image_sizes_advanced’, function( $sizes, … Read more

How to create interactive charts on WordPress?

It is possible to create interactive charts on a WordPress site. This will require custom code on your end to accomplish, but several JavaScript libraries exist that can help facilitate this. I have created custom charts using javascript libraries such as D3.js. Here is a great resource to get you started: https://getflywheel.com/layout/how-to-add-charts-to-your-wordpress-site-using-d3-js/.

get_post_gallery with Gutenberg

Using birgire’s suggestions, I came up with the following solution that is working well with both the old pre-WP 4.x data and the newer posts that have been added under 5.0. // if there is a gallery block do this if (has_block(‘gallery’, $post->post_content)) { $post_blocks = parse_blocks($post->post_content); $ids = $post_blocks[0][attrs][ids]; } // if there is … Read more

wp_download_url() for dynamically generated image

Without more information, it’s hard to tell what the reason is, for a specific answer you might want to show your code. The following uploads the lady to the media library: $url=”https://res.cloudinary.com/demo/image/upload/w_400,h_400,c_crop,g_face,r_max/w_200/lady.jpg”; // $post_id = 0 to not attach to specific post media_sideload_image( $url, 0 ); If you’re outside /wp-admin, you’ll need: require_once(ABSPATH . ‘wp-admin/includes/media.php’); … Read more

Get image thumbnail size urls in media library

This is the solution I came up with – it replaces WP’s default Full URL input with a list of any supplied thumbnail sizes right in the media library popup. add_action( ‘print_media_templates’, ‘ezific_media_tmpl_image_thumbnail_urls’ ); function ezific_media_tmpl_image_thumbnail_urls() { /* // The prior URL HTML; /wp-includes/media-template.php // found with regex in variable old_html_regex below <label class=”setting” data-setting=”url”> … Read more

Dashboard Create Gallery missing

Now I know why no one was answering. It looks like I have been a dufus and completely missed that the fine folks at WP moved the “Create Gallery” option from where I was used to having it located after upgrading to the Gutenberg editor. Oh, well! I’m surprised where they put it, and that … Read more

add alt text to images loaded from json with media_sideload_image

Once you have the attachment ID you can add alt text by setting the _wp_attachment_image_alt post meta for the attachment: update_post_meta( $attachment_id, ‘_wp_attachment_image_alt’, ‘Alt text here’ ); To get the attachment ID from media_sideload_image() you can set the 4th argument to ‘id’: $attachment_id = media_sideload_image( $file, $post_id, $desc, ‘id’ ); if ( ! is_wp_error( $attachment_id … Read more