<?php

if ( ! defined( 'ABSPATH' ) ) exit;

function docuchat_get_image_from_name($imageName) {
  if (!null == get_option( DOCUCHAT_IMAGES_IDS )) {
                    $imagesIds = unserialize(get_option(DOCUCHAT_IMAGES_IDS));

                foreach($imagesIds as $imageId){ 
                    $split = explode('.',  explode('/docuchat_', wp_get_attachment_metadata( $imageId )['file'])[1]) ;
                    if($split[0] == $imageName){
                   return $imageId;
                }
            }
  } else {
    return null;
  }
}