I’m in need of some help after a few days of hours pulling my hair out…
I’m fairly new with PHP, but I can usually get myself around some issues.
I’ve created a Desktop & Mobile image upload field and need to display them multiple times within a data display.
See below… Would something like this even be possible? It keeps breaking my website (Bad Gateway) when I attempt.
A beer goes to anyone kind enough to lend their thoughts…
Cheers!
<?php
$dimage = get_field(‘hero_highlight_2_d2’);
$mimage = get_field(‘hero_highlight_2_m2’);
if( !empty($dimage) ):
$dbig = ‘hero-highlight-2-866×480-dbig’;
$dsmall = ‘hero-highlight-2-433×240-dsmall’;
$mbig = ‘hero-highlight-2-760×680-mbig’;
$msmall = ‘hero-highlight-2-380×340-sbig’;
$deskx2 = $dimage[‘sizes’][ $dbig ];
$desk = $dimage[‘sizes’][ $dsmall ];
$mobilex2 = $mimage[‘sizes’][ $mbig ];
$mobile = $mimage[‘sizes’][ $msmall ];
?>
<source data-srcset=”<?php echo $desk; ?> 1x, <?php echo $deskx2; ?> 2x” media=”(min-width: 1080px)” srcset=”<?php echo $desk; ?> 1x, <?php echo $deskx2; ?> 2x”>
1x, <?php echo $mobilex2; ?> 2x” alt=”” srcset=”<?php echo $mobile; ?> 1x, <?php echo $mobilex2; ?> 2x”>
</picture>
<noscript><picture class=”picture”>
<source srcset=”<?php echo $mobile; ?> 1x, <?php echo $deskx2; ?> 2x” media=”(min-width: 1080px)” />
1x, <?php echo $deskx2; ?> 2x” alt=”” />
</picture></noscript> iTunes Login
<?php endif; ?>
I think that this is possible and you should go for it!