<?php
$bosa_driving_school_blogorganizationimageoneID 	= get_theme_mod( 'bosa_driving_school_blog_organization_image_one','');
$bosa_driving_school_blogorganizationimagetwoID 	= get_theme_mod( 'bosa_driving_school_blog_organization_image_two','');       
$bosa_driving_school_blogorganizationimagethreeID 	= get_theme_mod( 'bosa_driving_school_blog_organization_image_three','');
$bosa_driving_school_blogorganizationoneID 			= get_theme_mod( 'bosa_driving_school_blog_organization_one','');
$bosa_driving_school_blogorganizationtwoID 			= get_theme_mod( 'bosa_driving_school_blog_organization_two','');
$bosa_driving_school_blogorganizationthreeID 		= get_theme_mod( 'bosa_driving_school_blog_organization_three','');
 
$bosa_driving_school_organizations_array = array();
$bosa_driving_school_has_organization_img = false;
$bosa_driving_school_has_organization_txt = false;
if( !empty( $bosa_driving_school_blogorganizationimageoneID ) ){
	$bosa_driving_school_blog_organization_one  = wp_get_attachment_image_src( $bosa_driving_school_blogorganizationimageoneID,'bosa-driving-school-420-300');
 	if ( is_array(  $bosa_driving_school_blog_organization_one ) ){
 		$bosa_driving_school_has_organization_img = true;
 		$bosa_driving_school_has_organization_txt = true;
   	 	$bosa_driving_school_blog_organizations_one = $bosa_driving_school_blog_organization_one[0];
   	 	$bosa_driving_school_organizations_array['image_one'] = array(
			'ID' => $bosa_driving_school_blog_organizations_one,
			'txt' => $bosa_driving_school_blogorganizationoneID,
		);	
  	}
}
if( !empty( $bosa_driving_school_blogorganizationimagetwoID ) ){
	$bosa_driving_school_blog_organization_two = wp_get_attachment_image_src( $bosa_driving_school_blogorganizationimagetwoID,'bosa-driving-school-420-300');
	if ( is_array(  $bosa_driving_school_blog_organization_two ) ){
		$bosa_driving_school_has_organization_img = true;
		$bosa_driving_school_has_organization_txt = true;	
        $bosa_driving_school_blog_organizations_two = $bosa_driving_school_blog_organization_two[0];
        $bosa_driving_school_organizations_array['image_two'] = array(
			'ID' => $bosa_driving_school_blog_organizations_two,
			'txt' => $bosa_driving_school_blogorganizationtwoID,
		);	
  	}
}
if( !empty( $bosa_driving_school_blogorganizationimagethreeID ) ){	
	$bosa_driving_school_blog_organization_three = wp_get_attachment_image_src( $bosa_driving_school_blogorganizationimagethreeID,'bosa-driving-school-420-300');
	if ( is_array(  $bosa_driving_school_blog_organization_three ) ){
		$bosa_driving_school_has_organization_img = true;
		$bosa_driving_school_has_organization_txt = true;
      	$bosa_driving_school_blog_organizations_three = $bosa_driving_school_blog_organization_three[0];
      	$bosa_driving_school_organizations_array['image_three'] = array(
			'ID' => $bosa_driving_school_blog_organizations_three,
			'txt' => $bosa_driving_school_blogorganizationthreeID,
		);	
  	}
}

if( !get_theme_mod( 'bosa_driving_school_disable_organization_section', true ) && $bosa_driving_school_has_organization_img && $bosa_driving_school_has_organization_txt ){ ?>
	<section class="organization-section">
		<div class="row">
			<?php foreach( $bosa_driving_school_organizations_array as $bosa_driving_school_each_organizations ){ ?>
				<div class="col-md-4 col-sm-6">
					<article class="organization-content-wrap">
						<figure class= "featured-image">
							<img src="<?php echo esc_url( $bosa_driving_school_each_organizations['ID'] ); ?>">
						</figure>
						<?php if( !empty( $bosa_driving_school_each_organizations['txt'] ) ) { ?>
							<div class="organization-txt">
								<?php
									echo esc_html( $bosa_driving_school_each_organizations['txt'] );
								?>
							</div>
						<?php } ?>
					</article>
				</div>
			<?php } ?>
		</div>	
	</section>
<?php } 