You have to write custom code to get the attachment id and post_parent by name/ slug or filename(if it has not been changed during the uploading of files).
Put the below code in your theme's functions.php file
if( ! ( function_exists( 'wp_get_attachment_by_post_name' ) ) ) {
function wp_get_attachment_by_post_name( $post_name ) {
$args = array(
'post_per_page' => 1,
'post_type' => 'attachment',
'name' => trim ( $post_name ),
);
$get_posts = new Wp_Query( $args );
if ( $get_posts->posts[0] )
return $get_posts->posts[0];
else
return false;
}
}
then you can call the function where you need it like below :--
$attachment = wp_get_attachment_by_post_name( $post_name );
// Replace post_name by the name/slug of the attachment
// It will give you an object, which you can render like below to get the ID and post_parent
if ( $attachment ) {
echo $attachment->ID; // Gives the id of the attachment
echo $attachment->post_parent; // Gives the post_parent id
echo $attachment->post_title; // Gives the attachment title.
}