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 image option in nav menu in wordpress

How to add a custom email functionality in woocommerce,wordpress for example new email template for shipping order

How to change user id on checkout page for assign order to different user in woocommerce wordpress