packages/kirki-framework/core/src/Helper.php
public static function get_image_id( $url ) {
		global $wpdb;
		if ( empty( $url ) ) {
			return 0;
		}

		$attachment = wp_cache_get( 'kirki_image_id_' . md5( $url ), null );
		if ( false === $attachment ) {
			$attachment = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE guid = %s;", $url ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
			wp_cache_add( 'kirki_image_id_' . md5( $url ), $attachment, null );
		}

		if ( ! empty( $attachment ) ) {
			return $attachment[0];
		}
		return 0;
	}
public static function get_image_id( $url ) {
		global $wpdb;
		if ( empty( $url ) ) {
			return 0;
		}

		$attachment = wp_cache_get( 'kirki_image_id_' . md5( $url ), null );
		if ( false === $attachment ) {
			$attachment = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE guid = %s;", $url ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
			wp_cache_add( 'kirki_image_id_' . md5( $url ), $attachment, null );
		}

		if ( ! empty( $attachment ) ) {
			return $attachment[0];
		}
		return 0;
	}
public static function get_image_id ( $ url ) { global $ wpdb ; if ( empty ( $ url ) ) { return 0 ; } $ attachment = wp_cache_get ( 'kirki_image_id_' . md5 ( $ url ) , null ) ; if ( false === $ attachment ) { $ attachment = $ wpdb -> get_col ( $ wpdb -> prepare ( "SELECT ID FROM $wpdb->posts WHERE guid = %s;" , $ url ) ) ; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery wp_cache_add ( 'kirki_image_id_' . md5 ( $ url ) , $ attachment , null ) ; } if ( ! empty ( $ attachment ) ) { return $ attachment [ 0 ] ; } return 0 ; }
Returns the attachment object

@static
@access public
@see https://pippinsplugins.com/retrieve-attachment-id-from-image-url/
@param string $url URL to the image.
@return int|string Numeric ID of the attachement.
Returns the attachment object