dodanie obrazka na stronie – różne sposoby

dodanie obrazka z pola ACF z opcją obiect image:



<div class="home-slider-inner">
	<?php while ( have_rows('slider') ) : the_row(); $imgID = get_sub_field('image'); $img = wp_get_attachment_image_src($imgID, 'large-slide');?>
	
<div class="slide">

<div class="image" style="background-image:url(<?php echo $img[0];?>); background-position:<?php the_sub_field('slider_image_position'); ?>">
		</div>

 <!-- /.image -->
	</div>

<!-- /slide -->
	<?php endwhile;?>
</div>

<!-- /.home-slider-inner -->

 

dodanie obrazka z ACF object image ze sprawdzeniem alt:


<?php $image = get_field('img'); $image_url = $image['url']; $image_alt = $image['alt']; if (empty($image_alt)) : $image_alt = $image['title']; endif; ?>

<img src="<?php echo $image_url;?>" alt="<?php echo $image_alt;?>"/>

 

dodanie obrazka z ACF object image ze sprawdzeniem alt i pobraniem wymiaru zdefiniowanej miniatury:


<?php $image = get_field('img'); $size = 'my-thumb'; $thumb = $image['sizes'][ $size ]; $image_alt = $image['alt']; if (empty($image_alt)) : $image_alt = $image['title']; endif; ?>

<img src="<?php echo $thumb;?>" alt="<?php echo $image_alt;?>"/>