trey
1/1/2018 - 6:11 PM

search-media-library.php

<?php
function my_search_media_library( $image ) {
    global $wpdb;
	$all_images = array();

    $query = "SELECT * FROM " . $wpdb->posts . " WHERE guid LIKE '%" . $image . "%'";
    $results = $wpdb->get_results( $query );
	
	if ( $results ) {
		foreach ( $results as $result ) {
			$all_images[] = basename( $result->guid );	
		}
	}

    return implode( ",", $all_images );
}
?>