Viewing 1 reply thread
  • Author
    Posts
    • #8886
      Ico
      Member

      Hi,

      I have local env and live server, both php 5.6.32 with Piklist 0.9.9.17

      I have a setting and repeater field as follow:

      /*
      title: Clients
      Setting: lc_settings
      Tab: Clients
      Tab Order: 3
      */
      
      piklist('field', array(
       'type' => 'group',
       'field' => 'hp_clients',
       'label' => 'Clients',
       'help' => 'One logo per group',
       'add_more' => true,
       'fields' => array(
        array(
         'type' => 'file',
         'field' => 'logo_image',
         'label' => 'Client logo',
         'required' => true,
         'options' => array(
          'basic' => false,
          'modal_title' => 'Choose image',
          'button' => 'Select'
         ),
         'columns' => 8,
         'validate' => array(array(
          'type' => 'limit',
          'options' => array(
           'min' => 1,
           'max' => 1
          ))),
         'attributes' => array(
          'class' => 'regular-text'
         )),
       )
      ));

      This is how I display the logos:

      <?php if (!empty($clients)): ?>
            <?php foreach ($clients as $client): ?>
              <?php $attachment_id = $client['logo_image']; ?>
              <img src="<?php echo wp_get_attachment_url($attachment_id); ?>">
            <?php endforeach; ?>
          <?php endif; ?>

      Here is the weird part

      $client[‘logo_image’] is array on my local server ( the image ID is $client[‘logo_image’][0] and on server env $client[‘logo_image’] returns the ID itself.

      If I leave $attachment_id = $client['logo_image']; it works on server, but not in local. Why is this inconsistency?

    • #8887
      Ico
      Member

      I can use something like <?php $attachment_id = is_array($client['logo_image']) ? $client['logo_image'][0] : $client['logo_image']; ?> , but the inconsistency still bugs me.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.