PluginProbe
Property Hive / 2.3.1
Property Hive v2.3.1
2.3.1 2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 1.4.61 All 261 releases
propertyhive / includes / salient-widgets / property-image-html.php

property-image-html.php in Property Hive 2.3.1, at includes/salient-widgets/property-image-html.php

86 lines 4.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
5 extract(shortcode_atts(array(
6 "image_number" => "",
7 "image_size" => "",
8 "output_ratio" => "",
9 ), $atts));
10
11 global $property;
12
13 if ( !isset($property->id) ) {
14 return;
15 }
16
17 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- WPBakery html_template local variable; this file is a framework-rendered view receiving $atts/$this, and PrefixAllGlobals sees it outside the framework render scope.
18 $image_number = 1;
19 if ( isset($atts['image_number']) && $atts['image_number'] != '' && is_numeric($atts['image_number']) )
20 {
21 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- WPBakery html_template local variable; this file is a framework-rendered view receiving $atts/$this, and PrefixAllGlobals sees it outside the framework render scope.
22 $image_number = (int)$atts['image_number'];
23 }
24
25 if ( $output_ratio != '' )
26 {
27 // output div with image as background
28 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- WPBakery html_template local variable; this file is a framework-rendered view receiving $atts/$this, and PrefixAllGlobals sees it outside the framework render scope.
29 $url = '';
30 if ( get_option('propertyhive_images_stored_as', '') == 'urls' )
31 {
32 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- WPBakery html_template local variable; this file is a framework-rendered view receiving $atts/$this, and PrefixAllGlobals sees it outside the framework render scope.
33 $photos = $property->_photo_urls;
34 if ( isset($photos[$image_number-1]) )
35 {
36 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- WPBakery html_template local variable; this file is a framework-rendered view receiving $atts/$this, and PrefixAllGlobals sees it outside the framework render scope.
37 $url = $photos[$image_number-1]['url'];
38 }
39 }
40 else
41 {
42 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- WPBakery html_template local variable; this file is a framework-rendered view receiving $atts/$this, and PrefixAllGlobals sees it outside the framework render scope.
43 $gallery_attachment_ids = $property->get_gallery_attachment_ids();
44
45 if ( isset($gallery_attachment_ids[$image_number-1]) )
46 {
47 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- WPBakery html_template local variable; this file is a framework-rendered view receiving $atts/$this, and PrefixAllGlobals sees it outside the framework render scope.
48 $url = wp_get_attachment_image_src( $gallery_attachment_ids[$image_number-1], $atts['image_size'] );
49 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- WPBakery html_template local variable; this file is a framework-rendered view receiving $atts/$this, and PrefixAllGlobals sees it outside the framework render scope.
50 $url = $url[0];
51 }
52 }
53
54 // convert ratio to percentage
55 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- WPBakery html_template local variable; this file is a framework-rendered view receiving $atts/$this, and PrefixAllGlobals sees it outside the framework render scope.
56 $numbers = explode(':', $output_ratio);
57 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- WPBakery html_template local variable; this file is a framework-rendered view receiving $atts/$this, and PrefixAllGlobals sees it outside the framework render scope.
58 $percent = ( ( (int)$numbers[1] / (int)$numbers[0] ) * 100 ) . '%';
59
60 echo '<div style="background:url(' . esc_url($url) . ') no-repeat center center; background-size:cover; padding-bottom:' . esc_attr($percent) . '">';
61 }
62 else
63 {
64 // output <img>
65 if ( get_option('propertyhive_images_stored_as', '') == 'urls' )
66 {
67 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- WPBakery html_template local variable; this file is a framework-rendered view receiving $atts/$this, and PrefixAllGlobals sees it outside the framework render scope.
68 $photos = $property->_photo_urls;
69 if ( isset($photos[$image_number-1]) )
70 {
71 echo '<img src="' . esc_url($photos[$image_number-1]['url']) . '" alt="">';
72 }
73 }
74 else
75 {
76 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- WPBakery html_template local variable; this file is a framework-rendered view receiving $atts/$this, and PrefixAllGlobals sees it outside the framework render scope.
77 $gallery_attachment_ids = $property->get_gallery_attachment_ids();
78
79 if ( isset($gallery_attachment_ids[$image_number-1]) )
80 {
81 echo wp_get_attachment_image( $gallery_attachment_ids[$image_number-1], $atts['image_size'] );
82 }
83 }
84 }
85
86 do_action( 'propertyhive_salient_widget_property_image_render_after', $atts, $property );