Using only the first attached image
-
Hello! First of all I would like to thank Mike for this really great Plugin! I am testing WP Tiles for the relaunch of my site and it works fantastic. The only thing I am missing is to force WP Tiles to use only the first attached image and no other image. I am sure this could be done, if you rearrange the following code from the end of wp-tiles.php. I have tried different changes, but due to a lack of PHP knowledge I seem uable to do it. Maybe someone could help me with this or point me in the right direction?
public function get_first_image ( $post ) { $tile_image_size = apply_filters( 'wp-tiles-image-size', 'post-thumbnail', $post ); if ( $post_thumbnail_id = get_post_thumbnail_id( $post->ID ) ) { $image = wp_get_attachment_image_src( $post_thumbnail_id, $tile_image_size, false ); return $image[0]; } $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 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Using only the first attached image’ is closed to new replies.