post thumb nail
You use the function get_the_post_thumbnail() which returns a string. So you need to print that string with echo or use the_post_thumbnail() which echos itself.
You use the function get_the_post_thumbnail() which returns a string. So you need to print that string with echo or use the_post_thumbnail() which echos itself.
You need to register the image size first using add_image_size(), for example: add_action( ‘after_setup_theme’, ‘cyb_add_image_sizes’ ); function cyb_add_image_sizes() { add_image_size( ‘my-image-size-name’, 120, 120, true ); } Then, you can use the image_size_names_choose filter (you have misspelled it with image_size_names_chooser): add_filter( ‘image_size_names_choose’, ‘rudr_new_image_sizes’ ); function rudr_new_image_sizes( $sizes ) { $addsizes = array( “my-image-size-name” => ‘Misha size’ … Read more
This solution will add the data-fancybox=”group” to gallery links produced by the default shortcode. This has been tested and works regardless of whether themes have HTML5 theme support enabled for galleries or not. The solution works by using the post_gallery filter to gain access to the gallery shortcode’s output. From there, the HTML is parsed … Read more
I think wp_get_attachment_srcset() is what you are looking for. $srcset = wp_get_attachment_image_srcset( $image[‘id’], array( 100, 100 ) ); Now you can escape the HTML and use it in your code. <img src=”https://wordpress.stackexchange.com/questions/276972/PATH HERE” srcset=”https://wordpress.stackexchange.com/<?php echo esc_attr( $srcset ); ?>”>
If your just going to be showing images jQuery Cycle is the way to go. It is very light and you simply call the js in your theme then wrap your images in a div ie: <div class=”pics”> <img src=”https://wordpress.stackexchange.com/questions/1807/images/beach1.jpg” width=”200″ height=”200″ /> <img src=”images/beach2.jpg” width=”200″ height=”200″ /> <img src=”images/beach3.jpg” width=”200″ height=”200″ /> </div> Then … Read more
if the image is inserted (attached) into the post and not a external link: function get_my_thumbnail($post_id, $size, $attr=””){ // check of featured image first $t = get_post_thumbnail_id($post_id); // no featured image set, check post attachments if(empty($t)){ $attachments = get_children(array( ‘post_parent’ => $post_id, ‘post_status’ => ‘inherit’, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, ‘order’ => ‘ASC’, ‘orderby’ … Read more
This is all I can get from reading the source code for the wp_handle_upload function in wp-admin/includes/file.php. WordPress keeps the original uploaded file (usually) – see below… WordPress does apply JPEG compression to resized images when the source is a JPEG. The default JPEG compression level is 90. You can adjust the JPEG compression level … Read more
If I’m understanding correctly, each post has a filemaker, and each filemaker has only one photo? The structure is kind of unclear. Anyways, one way is top use media_sideload_image like below. However, media_sideload_image WON’T work with local files (a path on your filesystem), so you need to change your $file[‘url’] to be a valid URL … Read more
That is simple: <?php $categories = get_the_category($post->ID); if ($categories) { $category_ids = array(); foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id; $args=array( ‘category__in’ => $category_ids, ‘post__not_in’ => array($post->ID), ‘showposts’=> 5, // Number of related posts that will be shown. ‘caller_get_posts’=> 1 ); $my_query = new wp_query($args); if( $my_query->have_posts() ) { echo ‘<h3>Related Posts</h3>’; echo ‘<ul>’; while ($my_query->have_posts()) … Read more
The task It’s not as easy, as it looks at a first glance. The main problem is, that you can define your own shortcode and simply override the default. Actually that’s what some themes are doing (blame you ThemeForest authors!). In this case, simply hooking into post_gallery won’t work in every case. Drawbacks for post_gallery … Read more