1
0
Fork 0
forked from lino/radar-wp

Add support for images to shortcode.

This commit is contained in:
ekes 2017-06-09 15:28:57 +01:00
parent 4ed51243b5
commit dd31752b4b
2 changed files with 25 additions and 3 deletions

View file

@ -29,7 +29,10 @@ function radar_retrieve_events($settings) {
return $events;
}
function radar_retrieve_entities(array $entities) {
function radar_retrieve_entities($entities) {
if (!is_array($entities)) {
$entities = [$entities];
}
$client = radar_client();
return $client->retrieveEntityMultiple($entities);
}
@ -147,7 +150,7 @@ function _radar_method_lookup($type, $field) {
'date' => 'getDates',
'body' => 'getBody',
'url' => 'getUrlView',
'image' => 'getImageRaw',
'image' => 'getImage',
'price' => 'getPrice',
'price_category' => 'getPriceCategory',
'email' => 'getEmail',
@ -187,7 +190,13 @@ function _radar_method_lookup($type, $field) {
'link' => 'getLink',
'phone' => 'getPhone',
'opening_times' => 'getOpeningTimes',
)
),
'image' => array(
'title' => 'getTitle',
'mime' => 'getMime',
'url' => 'getUrl',
'size' => 'getSize',
),
);
return !empty($lookup[$type][$field]) ? $lookup[$type][$field] : FALSE;
}

View file

@ -41,6 +41,7 @@ function radar_shortcode_events($attributes, $content = '') {
'price_category:title',
'price',
'link',
'image:url',
'body',
'group:title',
'group:url',
@ -193,6 +194,18 @@ function radar_shortcode_field_url_value($field, $type, $item, $parents, $shortc
}
add_filter('radar_shortcode_field_value', 'radar_shortcode_field_url_value', 12, 5);
/**
* Format image.
*/
function radar_shortcode_image_value($field, $type, $item, $parents, $shortcode) {
if ($type == 'image' && $field['field'] == 'url' && $field['value']) {
$field['output'] = '<img src="'. $field['value'] .'" \>';
}
return $field;
}
add_filter('radar_shortcode_field_value', 'radar_shortcode_image_value', 12, 5);
//
// 'radar_shortcode_field_html'
//