# adminify/2.0.0/lib/adminify-framework/fields/gallery/gallery.php

Adminify – White Label, Admin Menu Editor, Login Customizer, version 2.0.0. 53 lines.

- Page: https://pluginprobe.com/plugins/adminify/2.0.0/code/lib/adminify-framework/fields/gallery/gallery.php
- Raw: https://pluginprobe.com/plugins/adminify/2.0.0/raw/lib/adminify-framework/fields/gallery/gallery.php
- Modified: 2022-01-24T14:44:22+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/adminify/2.0.0/code/lib/adminify-framework/fields/gallery/gallery.php#L10-L20`.

```php
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
/**
 *
 * Field: gallery
 *
 * @since 1.0.0
 * @version 1.0.0
 *
 */
if ( ! class_exists( 'ADMINIFY_Field_gallery' ) ) {
  class ADMINIFY_Field_gallery extends ADMINIFY_Fields {

    public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
      parent::__construct( $field, $value, $unique, $where, $parent );
    }

    public function render() {

      $args = wp_parse_args( $this->field, array(
        'add_title'   => esc_html__( 'Add Gallery', 'adminify' ),
        'edit_title'  => esc_html__( 'Edit Gallery', 'adminify' ),
        'clear_title' => esc_html__( 'Clear', 'adminify' ),
      ) );

      $hidden = ( empty( $this->value ) ) ? ' hidden' : '';

      echo $this->field_before();

      echo '<ul>';
      if ( ! empty( $this->value ) ) {

        $values = explode( ',', $this->value );

        foreach ( $values as $id ) {
          $attachment = wp_get_attachment_image_src( $id, 'thumbnail' );
          echo '<li><img src="'. esc_url( $attachment[0] ) .'" /></li>';
        }

      }
      echo '</ul>';

      echo '<a href="#" class="button button-primary adminify-button">'. $args['add_title'] .'</a>';
      echo '<a href="#" class="button adminify-edit-gallery'. esc_attr( $hidden ) .'">'. $args['edit_title'] .'</a>';
      echo '<a href="#" class="button adminify-warning-primary adminify-clear-gallery'. esc_attr( $hidden ) .'">'. $args['clear_title'] .'</a>';
      echo '<input type="text" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $this->value ) .'"'. $this->field_attributes() .'/>';

      echo $this->field_after();

    }

  }
}

```
