Using attached instead of featured image
-
Hi!
I want to force the plugin to use only the attached image (the first one), instead of the featured image.I did find this thread https://www.ads-software.com/support/topic/using-only-the-first-attached-image?replies=7, but I can’t seem to get it to work. Some help would be greatly appreciated!
In my wp-tiles-class.php, I’m not sure where to make the changes. I’ve found “Returns the first image” and “Finds the first relevant image to a post”, and I don’t really know which one is which… ??
This is what I’ve tried – does not work (featured images are still used)
/** * Finds the first relevant image to a post * * Searches for a featured image, then the first attached image, then the first image in the source. * * @param WP_Post $post * @return string Source * @sice 0.5.2 */ private function _find_the_image( $post ) { $tile_image_size = apply_filters( 'wp-tiles-image-size', 'post-thumbnail', $post ); $images = get_children( array( 'post_parent' => $post->ID, 'numberposts' => 1, 'post_mime_type' => 'image' ) ); if ( !empty( $images ) ) { $images = current( $images ); $src = wp_get_attachment_image_src( $images->ID, $size = $tile_image_size ); return $src[0]; } if ( !empty( $post->post_content ) ) { $xpath = new DOMXPath( @DOMDocument::loadHTML( $post->post_content ) ); $src = $xpath->evaluate( "string(//img/@src)" ); return $src; } return ''; }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Using attached instead of featured image’ is closed to new replies.