14

I found the culprit! WordPress 5.3 introduced additional image sizes which can be found via /wp-includes/media.php. Updating my function, like so, removed the extra sizes: function remove_default_image_sizes( $sizes) { unset( $sizes['large']); // Added to remove 1024 unset( $sizes['thumbnail']); unset( $sizes['medium']); unset( $sizes['...


3

Attachments in WP are stored as posts of type attachment which reference files physically stored in the uploads folder. This is why if you FTP a file into the uploads folder it doesn't appear in the media library. This means the media library is a post archive, much like other post archives in the admin and frontend. Specifically listing posts of type ...


3

I think you could the code working, if you used the current term as the selector as there's only one featured image and multiple links for each term. For example, first add the term to the image classes, <img class="img-fluid ga-img ga-img-<?php echo $term->slug; ?>" src="<?php echo esc_url($ga_url);?>"> Then add the term to every ...


3

The solution is simple, don't echo the result of that function, there is no result to echo. echo the_post_thumbnail(array(155,55)); Is equivalent to something like this: echo ''; the_post_thumbnail(array(155,55)); Functions that begin with the_ in WP don't return things, they output things. Some of them let you pass a parameter that lets them return ...


3

Ignoring our off-topic request for a plugin, the good news is: yes, this is possible. On the other hand, it is quite some work, so I will give just an outline here. WordPress does have built-in image manipulation. The default one is Image Magick. WordPress' image editor class, however, only offers a subset of what Image Magick is actually capable of. This ...


3

You can check mime type of uploaded image before upload to media. Add mimeTypes in $allowmimeType which you want to allow. then check uploaded files mimetype $fileMimeType. If not found in allowed mimetype then return false. // Insert Attachment function insert_attachment($file_handler, $post_id, $setthumb='false') { if ($_FILES[$file_handler]['error'] ...


3

This behaviour was newly introduced by WordPress with version 5.3 (released on 12th of November 2019). So if you updated to that version, WP is behaving according to design. The announcement post for the new version only mentions it as including improved large image support for uploading non-optimized, high-resolution pictures in the section "Block ...


3

The first argument of get_the_post_thumbnail() is not the image size that you want to use. It's the ID or object of the post whose thumbnail you want to get. To get the thumbnail size, set the second argument to 'thumbnail'. The first argument can just be set to null to get it for the current post: $news .= get_the_post_thumbnail( null, 'thumbnail' );


2

Several things could be impacting the image quality, but the biggest impact is calling the_post_thumbnail() without giving it a size. By default that will get the "thumbnail" image size, which by default is 150x150 pixels. Try this instead: the_post_thumbnail('full', array('class' => ' responsiveThumbnail')); Then you'll be pulling the full-size image ...


2

Given this hierarchy: Page 1 Page 2 Page 3 Page 4 This line, where $post represents Page 4: $parents = get_post_ancestors( $post->ID ); Will return 3 IDs, for these pages, in this order: Page 3 Page 2 Page 1 So this line: $id = ($parents) ? $parents[count($parents)-1]: $post->ID; Is the equivalent of: $id = ($parents) ? $parents[2]: $post-&...


2

Like this: 'alt' => get_the_title(). ' review' So the full code would be: <?php the_post_thumbnail('250px', array('class'=>"review-siteshot", 'alt' => get_the_title(). ' review' )); ?>


2

You should pass first argument as post id in get_the_post_thumbnail(). As you're getting thumbnail if look you can pass the id of post like get_the_post_thumbnail( get_the_ID(), 'thumbnail' ); you can also specify the size of the image your want to show as get_the_post_thumbnail( get_the_ID(), array( 100, 100) );


2

Warning (or note to other readers): Lots of JavaScript code ahead.. in fact, there's no PHP here. So I hope you already have some JavaScript skills prior to reading this answer. :) Thanks! I've also got a filter in place that sets the script type of my .js file to text/babel so JSX interprets correctly. I don't think I've missed anything. But for ...


2

The problem is: the_post_thumbnail() outputs its content immediately. It's basically like echoing instead of returning. To fix it, you should be able to just replace the_post_thumbnail('thumbnail', ['class' => 'droplet-img', 'title' => get_the_title()]) with get_the_post_thumbnail('thumbnail', ['class' => 'droplet-img', 'title' => ...


2

Wordpress has a hook for that. Here is a sample code: function featured_image_dimensions( $content, $post_id, $thumbnail_id ){ $help_text = '<p>' . __( 'recommended dimensions - H980px by W450px', 'my_domain' ) . '</p>'; return $help_text . $content; } add_filter( 'admin_post_thumbnail_html', 'featured_image_dimensions', 10, 3 ); Add ...


1

Hey you have to use the below logic to handle the above conditions, it will work. if (!is_user_logged_in() && has_tag('private')) { ?> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> <img src="<?php bloginfo('template_directory'); ?>/img/default-login.jpg" alt="<?php ...


1

So this may be hacky.. I mean, compared to overriding the default Featured Image panel/component in the Gutenberg block editor, which is not exactly hard, but this one is much simpler and basically just needs a few lines of custom coding. (read till the end to see what I mean) And I've also tried & tested it working (with both the old/classic editor ...


1

These images sizes are defined by WordPress, and were added in WordPress 5.3. The comments in the source code describe them like this: These sizes are meant to enhance the way WordPress displays images on the front-end on larger, high-density devices. They make it possible to generate more suitable srcset and sizes attributes when the users upload large ...


1

It doesn't, WP supports responsive image markup, so your browser decides based on various factors such as pixel density, battery, network, viewport, etc


1

You could filter the the_post_thumbnail() function, which will dynamically show the assigned category image across all your custom post type, rather than using acf_save_post to save the category image in the post featured image meta field. By filtering the the_post_thumbnail() for your specific post type, this means if you change the image on category in the ...


1

Create "images" folder in current active theme the put "default-image.jpg" in that folder. <?php if ( has_post_thumbnail( ) ) { echo get_the_post_thumbnail( $page->ID, 'image' ); } else { ?> <img src="<?php echo get_template_directory_uri().'/images/default-image.jpg'; ?>"/> <?php } ?> Use path ...


1

It appears that it's eventually used as a parameter to wp_constrain_dimensions where '0' means 'no limit'. It's only used directly in media.php:85 } elseif ( 'medium_large' === $size ) { $max_width = intval( get_option( 'medium_large_size_w' ) ); $max_height = intval( get_option( 'medium_large_size_h' ) ); if ( intval( $content_width ) > 0 ...


1

The answer above was helpful. In the interest of others however, I thought I'd expand on it and post additional detail. First of all it's very important to properly import the component you wish to use. I have an error in my original code above for CheckBoxControl. const { CheckboxControl } = wp.editor; //incorrect should be const { CheckboxControl } = ...


1

this might work: $post_thumbnail_id = get_post_thumbnail_id($post->ID); $thumbnail_image = get_posts(array('p' => $post_thumbnail_id, 'post_type' => 'attachment')); if ($thumbnail_image && isset($thumbnail_image[0])) { $img_description = $thumbnail_image[0]->post_content; $img_caption = $thumbnail_image[0]->post_excerpt; $...


1

Are there native WordPress functions to manipulate images Yes, there's is the WP_Image_Editor class for manipulating images. But I don't think it is able to combine images. Unless the WP_Image_Editor_GD or WP_Image_Editor_Imagick subclasses support that somehow. You can use WP to query the posts in tag and get the featured images. Then use plain PHP to ...


1

Your theme might already have an animation feature, you can just add the class. You can add a plugin like so..https://wordpress.org/plugins/animate-it/ and add the class to the featured image property for it to work. If you use a builder (like Elementor) you can easily create your layouts and add animations to each element.


1

Option 1: force featured image on all posts Use the save_post hook, which runs twice per "save" action if you have revisions enabled. You can verify it's the final run by checking that there is $_POST data (it's empty the first time around). add_action('save_post', 'wpse_force_featured_image', 20, 2); function wpse_force_featured_image($post_id, $post) { ...


1

Try this function filter_image_sizes() { foreach ( get_intermediate_image_sizes() as $size ) { if (in_array( $size, array('medium', 'medium_large', 'large') ) ) { remove_image_size( $size ); } } } add_action('init', 'filter_image_sizes');


1

You can try this code. It will add a media button which will get the image url. I have commented the parts that I have deleted or added. function my_category_module() { // this action is deprecated //add_action('edit_category_form_fields', 'add_image_cat'); // Add these actions for edit and add add_action('edited_category', 'save_image'); ...


1

just remove ->id becouse you are yousing only the first ID in function $img = get_the_post_thumbnail ( $post->id, 'thumbnail' ); it must be like that : $img = get_the_post_thumbnail ( $post, 'thumbnail' );


Only top voted, non community-wiki answers of a minimum length are eligible