Read all sub directories and check images or read image




For Read all images from the specific folders use below code
$directories = glob($dir_path . '/*' , GLOB_ONLYDIR);
if(count($directories)>0)
{
    foreach($directories as $sub_dir)
    {
        if(is_dir($sub_dir))
        {
           
           //$images = glob($sub_dir.'/' . "*.jpg");
           $images =  scandir($sub_dir.'/');
            $scanned_directory = array_diff($images, array('..', '.'));
           
            foreach($scanned_directory as $image)
            {
                echo '<img src="'.$sub_dir.'/' . $image .'" />';
            }
        }
    }
}

Comments

Popular posts from this blog

How to add a custom sorting or order by option on category archive or product archive page in woocommerce wordpress

How to create a custom wp_list_table and bulk action in wordpress

How to add image option in nav menu in wordpress