Skip to content
Snippets Groups Projects
Commit dd31752b authored by ekes's avatar ekes
Browse files

Add support for images to shortcode.

parent 4ed51243
No related branches found
No related tags found
No related merge requests found
...@@ -29,7 +29,10 @@ function radar_retrieve_events($settings) { ...@@ -29,7 +29,10 @@ function radar_retrieve_events($settings) {
return $events; return $events;
} }
function radar_retrieve_entities(array $entities) { function radar_retrieve_entities($entities) {
if (!is_array($entities)) {
$entities = [$entities];
}
$client = radar_client(); $client = radar_client();
return $client->retrieveEntityMultiple($entities); return $client->retrieveEntityMultiple($entities);
} }
...@@ -147,7 +150,7 @@ function _radar_method_lookup($type, $field) { ...@@ -147,7 +150,7 @@ function _radar_method_lookup($type, $field) {
'date' => 'getDates', 'date' => 'getDates',
'body' => 'getBody', 'body' => 'getBody',
'url' => 'getUrlView', 'url' => 'getUrlView',
'image' => 'getImageRaw', 'image' => 'getImage',
'price' => 'getPrice', 'price' => 'getPrice',
'price_category' => 'getPriceCategory', 'price_category' => 'getPriceCategory',
'email' => 'getEmail', 'email' => 'getEmail',
...@@ -187,7 +190,13 @@ function _radar_method_lookup($type, $field) { ...@@ -187,7 +190,13 @@ function _radar_method_lookup($type, $field) {
'link' => 'getLink', 'link' => 'getLink',
'phone' => 'getPhone', 'phone' => 'getPhone',
'opening_times' => 'getOpeningTimes', 'opening_times' => 'getOpeningTimes',
) ),
'image' => array(
'title' => 'getTitle',
'mime' => 'getMime',
'url' => 'getUrl',
'size' => 'getSize',
),
); );
return !empty($lookup[$type][$field]) ? $lookup[$type][$field] : FALSE; return !empty($lookup[$type][$field]) ? $lookup[$type][$field] : FALSE;
} }
......
...@@ -41,6 +41,7 @@ function radar_shortcode_events($attributes, $content = '') { ...@@ -41,6 +41,7 @@ function radar_shortcode_events($attributes, $content = '') {
'price_category:title', 'price_category:title',
'price', 'price',
'link', 'link',
'image:url',
'body', 'body',
'group:title', 'group:title',
'group:url', 'group:url',
...@@ -193,6 +194,18 @@ function radar_shortcode_field_url_value($field, $type, $item, $parents, $shortc ...@@ -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); 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' // 'radar_shortcode_field_html'
// //
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment