PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.75
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.75
5.5.83 5.5.82 5.5.81 5.5.80 5.5.79 5.5.77 5.5.76 5.5.75 5.5.73 5.5.72 5.5.22 5.5.23 5.5.29 5.5.3 5.5.31 5.5.32 5.5.34 5.5.35 5.5.36 5.5.37 5.5.4 5.5.40 5.5.41 5.5.42 5.5.43 All 159 releases
wp-data-access / WPDataAccess / Simple_Form / WPDA_Simple_Form_Item_Image.php

WPDA_Simple_Form_Item_Image.php in WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards 5.5.75, at WPDataAccess/Simple_Form/WPDA_Simple_Form_Item_Image.php

64 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Suppress "error - 0 - No summary was found for this file" on phpdoc generation
5 *
6 * @package WPDataAccess\Simple_Form
7 */
8
9 namespace WPDataAccess\Simple_Form {
10
11 /**
12 * Class WPDA_Simple_Form_Item_Image
13 *
14 * Handles a database column of type image.
15 *
16 * @author Peter Schulz
17 * @since 2.5.0
18 */
19 class WPDA_Simple_Form_Item_Image extends WPDA_Simple_Form_Item_Media {
20
21 /**
22 * WPDA_Simple_Form_Item_Image constructor.
23 *
24 * @param array $args
25 */
26 public function __construct( $args = array() ) {
27 parent::__construct( $args );
28
29 $this->media_frame_title = __( 'Upload or select image(s) from your WordPress media library', 'wp-data-access' );
30 $this->media_frame_remove = __( 'Remove image(s)', 'wp-data-access' );
31 $this->media_types = 'image';
32 }
33
34 protected function show_item_media() {
35 if ( 'number' === $this->data_type ) {
36 // Column supports one image file.
37 $url = wp_get_attachment_url( $this->item_value );
38 if ( false !== $url ) {
39 $this->create_item_image( $url );
40 }
41 } else {
42 // Column supports multiple image files.
43 if ( null !== $this->item_value && '' !== $this->item_value ) {
44 $media_ids = explode( ',', $this->item_value );//phpcs:ignore - 8.1 proof
45 foreach ( $media_ids as $media_id ) {
46 $url = wp_get_attachment_url( $media_id );
47 $this->create_item_image( $url );
48 }
49 }
50 }
51 }
52
53 private function create_item_image( $url ) {
54 ?>
55 <span class="wpda_media_container wpda_image">
56 <img src="<?php echo esc_url( $url ); ?>" target="_blank">
57 </span>
58 <?php
59 }
60
61 }
62
63 }
64