Support

Account

Home Forums General Issues Is this even possible?

Solving

Is this even possible?

  • 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-866x480-dbig';
      $dsmall = 'hero-highlight-2-433x240-dsmall';
      $mbig = 'hero-highlight-2-760x680-mbig';
      $msmall = 'hero-highlight-2-380x340-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">
    
    <img class="lazyloaded" data-srcset="<?php echo $mobile; ?> 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)" />
      <img srcset="<?php echo $mobile; ?> 1x, <?php echo $deskx2; ?> 2x" alt="" />
    </picture></noscript>
    
    <?php endif; ?>
    
  • I’m assuming it’s not good practice, or even possible, to load multiple variables without a merge for the array… But how could one achieve so many loads?

    Error:

    /srv/www/alvogutters.com/current/web/app/uploads/cache/03a667ebdf064c1dd2cbe95a4d14cac784b91108.php:90:
    array (size=24)
    ‘ID’ => int 113
    ‘id’ => int 113
    ‘title’ => string ‘retail@desktop-2x’ (length=17)
    ‘filename’ => string ‘[email protected]’ (length=21)
    ‘filesize’ => int 41365
    ‘url’ => string ‘/app/uploads/2019/03/[email protected]’ (length=42)
    ‘link’ => string ‘https://alvogutters.local/home/retaildesktop-2x/&#8217; (length=48)
    ‘alt’ => string ” (length=0)
    ‘author’ => string ‘1’ (length=1)
    ‘description’ => string ” (length=0)
    ‘caption’ => string ” (length=0)
    ‘name’ => string ‘retaildesktop-2x’ (length=16)
    ‘status’ => string ‘inherit’ (length=7)
    ‘uploaded_to’ => int 6
    ‘date’ => string ‘2019-03-20 21:17:52’ (length=19)
    ‘modified’ => string ‘2019-03-20 21:17:52’ (length=19)
    ‘menu_order’ => int 0
    ‘mime_type’ => string ‘image/jpeg’ (length=10)
    ‘type’ => string ‘image’ (length=5)
    ‘subtype’ => string ‘jpeg’ (length=4)
    ‘icon’ => string ‘https://alvogutters.local/wp/wp-includes/images/media/default.png&#8217; (length=65)
    ‘width’ => int 866
    ‘height’ => int 480
    ‘sizes’ =>
    array (size=36)
    ‘thumbnail’ => string ‘/app/uploads/2019/03/retail@desktop-2x-150×150.jpg’ (length=50)
    ‘thumbnail-width’ => int 150
    ‘thumbnail-height’ => int 150
    ‘medium’ => string ‘/app/uploads/2019/03/retail@desktop-2x-300×166.jpg’ (length=50)
    ‘medium-width’ => int 300
    ‘medium-height’ => int 166
    ‘medium_large’ => string ‘/app/uploads/2019/03/retail@desktop-2x-768×426.jpg’ (length=50)
    ‘medium_large-width’ => int 768
    ‘medium_large-height’ => int 426
    ‘large’ => string ‘/app/uploads/2019/03/[email protected]’ (length=42)
    ‘large-width’ => int 866
    ‘large-height’ => int 480
    ‘hero-highlight-main’ => string ‘/app/uploads/2019/03/[email protected]’ (length=42)
    ‘hero-highlight-main-width’ => int 866
    ‘hero-highlight-main-height’ => int 480
    ‘hero-highlight-1’ => string ‘/app/uploads/2019/03/retail@desktop-2x-650×360.jpg’ (length=50)
    ‘hero-highlight-1-width’ => int 650
    ‘hero-highlight-1-height’ => int 360
    ‘hero-highlight-2-866×480-dbig’ => string ‘/app/uploads/2019/03/[email protected]’ (length=42)
    ‘hero-highlight-2-866×480-dbig-width’ => int 866
    ‘hero-highlight-2-866×480-dbig-height’ => int 480
    ‘hero-highlight-2-433×240-dsmall’ => string ‘/app/uploads/2019/03/retail@desktop-2x-433×240.jpg’ (length=50)
    ‘hero-highlight-2-433×240-dsmall-width’ => int 433
    ‘hero-highlight-2-433×240-dsmall-height’ => int 240
    ‘hero-highlight-2-760×680-mbig’ => string ‘/app/uploads/2019/03/retail@desktop-2x-760×421.jpg’ (length=50)
    ‘hero-highlight-2-760×680-mbig-width’ => int 760
    ‘hero-highlight-2-760×680-mbig-height’ => int 421
    ‘hero-highlight-2-380×340-sbig’ => string ‘/app/uploads/2019/03/retail@desktop-2x-380×211.jpg’ (length=50)
    ‘hero-highlight-2-380×340-sbig-width’ => int 380
    ‘hero-highlight-2-380×340-sbig-height’ => int 211
    ‘hero-highlight-3’ => string ‘/app/uploads/2019/03/retail@desktop-2x-670×480.jpg’ (length=50)
    ‘hero-highlight-3-width’ => int 670
    ‘hero-highlight-3-height’ => int 480
    ‘hero-highlight-4’ => string ‘/app/uploads/2019/03/retail@desktop-2x-520×480.jpg’ (length=50)
    ‘hero-highlight-4-width’ => int 520
    ‘hero-highlight-4-height’ => int 480

  • 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!

  • See below… Would something like this even be possible? It keeps breaking my website (Bad Gateway) when I attempt.

    <?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)” />Instagram profile picture
    1x, <?php echo $deskx2; ?> 2x” alt=”” />
    </picture></noscript>

    <?php endif; ?>

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Is this even possible?’ is closed to new replies.