Tag Info

New answers tagged

0

First, paste this function on your functions.php file. function catch_that_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('//i', $post->post_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img)){ //Defines a default image $first_img = "/images/default.jpg"; } ...


0

Use the filter post_thumbnail_html (source): function wpse_195454_post_thumbnail_html( $html ) { if ( $html ) $html = '<span class="wrap">' . $html . '</span>'; return $html; } add_filter( 'post_thumbnail_html', 'wpse_195454_post_thumbnail_html' );


0

It is perfectly fine to use animated gifs in any capacity you like in WordPress, even as featured images. When you upload an image, WordPress will process it into various shapes and sizes, as specified by your theme and possibly some plugins as well. The version of image that gets displayed is determined by your theme OR, if not specified, WordPress core ...


0

Have you looked at using add_image_size? Check it out here. It will allow you to crop images various ways. It will also allow you to use the standard the_post_thumbnail and pass it your custom image size when you go to output this on the front-end. I also just noticed that you said inside the content. One way would be to take the above function and wrap it ...


2

Look in your theme folder for a file called content.php. Make a copy and rename it to anything you like, such as vega.php. Adjust the code in vega.php to your liking. Change the call in index.php to get_template_part( 'vega', get_post_format() );


0

This is likely a tweak the theme author made to make the images in the theme responsive or adaptive. You may want to look at adding "min-height" to your CSS and this should address your problem. https://css-tricks.com/almanac/properties/m/min-height/ Also another thing to note if you using "100%" anything the actual dimension is governed by the parent ...


2

You need to set ignore_sticky_posts to true in your query arguments. This way you exclude sticky posts and only focus on the post ID's array being passed to post_in 'ignore_sticky_posts' => true, EDIT If this does not make much sense, please see my answer here to similar question where I have explained it a bit better. Be sure to check it out THE ...


0

What you are doing is right except that you are careless or you just copied code from somewhere else and pasted in without modifying it. <?php $sticky = get_option('sticky_posts'); if (empty($sticky)) { return; } $counter = 1; $posts = new WP_Query(array( 'posts_per_page' => 5, 'post__in' => $sticky, 'meta_query' => ...


1

You can get image url with wp_get_attachment_image_src and use in href. It's most often used to get the URL (src) for an image attachment: use the first element in the returned array. So instead of your code for featured thumbnail, you should use this. <?php if ( current_theme_supports( 'get-the-image' ) ) { $fullimage = ...


1

If you use the following code you may fix your problem. Give it a try.Paste this in your post.php <?php if ( current_theme_supports( 'get-the-image' ) ): $image_full=wp_get_attachment_image_src(get_post_thumbnail_id( $post->ID ), 'full'); $image_thumbnail=wp_get_attachment_image_src(get_post_thumbnail_id( $post->ID ), 'single-thumbnail'); ...


1

You may use the css hide one of the images for now until you figure it out. Coz nothing is clear from above code Add these lines to your style.css .entry-header figure{ display: none !important; } refresh your cache and you will the problem fixed


1

You should define add_image_size with fourth parameter to allow WordPress to crop your image to exact size. add_image_size ( 'single_post', 500, 200, true); Whether to crop images to specified height and width or resize Difference between soft and hard crop false - Soft proportional crop mode. true - Hard crop mode. array - Specify positioning of the ...


-1

This simply doesn't work. Wordpress resizes the images while uploading, so if you don't upload them again, nothing will happen.


1

You are not providing a correct attachement ID. Replace: $image_alt = get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true); With: $image_alt = get_post_meta( $image->id, '_wp_attachment_image_alt', true); Note: I assume that $image->id is correct because you use it later in your code and you get the expected result. Unfortunatley ...


0

you need to have predefined image sizes, WP have 3 default sizes as 100x100 thumbnail, 300x300 medium and 800x800 large, and I have an aditional size called img-polaroid 700x320 defined on functions.ini. So the code to get images is: $image_id=get_post_thumbnail_id(); $image_url = wp_get_attachment_image_src($image_id,'img-polaroid'); ...


0

jQuery( document ).ready(function() { jQuery("figure").addClass("wp-caption"); }); You could use jQuery to add a class.


0

Create a php script ( fpw-swap-thumbnails.php ) with the code below and put it in root of your site: <?php // load WordPress environment require( 'wp-load.php' ); $args = array( 'posts_per_page' => -1, 'post_type' => array( 'post', 'page' ), 'post_status' => 'publish' ); // get all published posts of type specified in $args $posts ...


0

... leads me to believe wp_get_attachment_image_src( $thumb_id, array(100, 100) )[0] would return a 100x100 thumbnail... That isn't quite what happens. Most of the work is done by image_downsize() as you can see from near the top of the wp_get_attachment_image_src() : 692 // get a thumbnail or intermediate image if there is one 693 if ...



Top 50 recent answers are included