New answers tagged

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 ...


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 ...


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 ...


0

What I aim is to create a gallery which contains all my featured thumbnail displayed in three column of the same size, like the Flick way but with a vertical alignment. did you try masonry.js? it's a javascript library that can help you create the gallery without the need to calculate the height of each image. if you decided to use masonry.js, you may need ...


0

I don't think you're far off but it looks like you may be overly complicating it unnecessarily....you mentioned that you're (also) using the "featured image" so I assume what you're trying to do is a) IF a youtube thumbnail exists in a custom field ('wtp_thumb_url') then use that one and if not then b) use the Post's Featured Image thumbnail. If I'...


0

thanks for your help. I used this variant of your code with a little diffrent preg_replace code. If the Image URL contain numbers like "-510x383.jpg" i had some Problems with your code. <?php if( is_single() ) { global $post; $pattern = '/<img.*src="([^"]+)"[^>]*>/'; $matches = []; preg_match_all( $pattern,...


0

If you want to get the actual images inside the post content, you can match them using a regular expression. To get just the images URLs and dimensions your code can be something like this: if( is_single() ) { global $post; // Match the image URLs inside the post content $pattern = '/<img.*src="([^"]+)"[^>]*>/'; $...


0

(function($){ $(document).ready(function(){ var items = []; $.getJSON('https://localhost/wordpress/wp-json/wp/v2/posts?category_name=portfolio&per_page=50&_embed', function(response){ console.log(response); $.each(response, function(key,val){ //console.log(val._embedded['wp:featuredmedia'][0].source_url); items.push(''+''...


0

I've run into trouble using the intermediate_image_sizes_advanced filter on a few sites lately. It seems like in WP 5.3 intermediate_image_sizes is more reliable. I would recommend unsetting unwanted sizes like this: add_filter('intermediate_image_sizes', 'remove_default_img_sizes', 10, 1); function remove_default_img_sizes($sizes) { $targets = ['medium'...


0

I made some changes to the code and just made a small screenshot with example how it's looking right now and how I would like it to look like (on the right side). Let's get to the code first, that's how it looks like right now: <h2 class="title_bar">Just Watched Videos</h2> <ul class="vlist"> <?php $args = array( '...


0

If the php file is gets included or required from functions.php file in parent theme all codes are added to runtime they are not replaced if you create files in similar directory structure. So, What can be replaced? Only files called via get_template_part() can be replaced this way. This is also true for any file in template hierarchy If the parent theme ...


0

So a few things... the_title() gets the title, but it includes mark-up, so when you use that in the title attribute it actually prints the code out with mark-up around it, like <h1>The Title</h1> which then breaks out of the title="". So the correct method for that would be: <a href="<?php the_permalink() ?>" title=&...


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 ...


0

Have you tried this plugin PDF Thumbnails ? This plugin generates a thumbnail from the first page in the uploaded document and names it as PDFNAME-thumbnail, then you can use this image as a featured image. this plugin is outdated, about 4 years ago so be sure for testing and compatibility.


Top 50 recent answers are included