Commit f9dd0058 authored by Chris Graham's avatar Chris Graham

Fix issues/ugliness with some Sitemap rep-image generation

parent ef1ebeb2
......@@ -706,11 +706,10 @@ function set_extra_request_metadata($metadata, $row = null, $content_type = null
$image_url = '';
if ($cma_info['thumb_field'] !== null) {
if ((strpos($cma_info['thumb_field'], 'CALL:') !== false) && ($content_id !== null)) {
$image_url = call_user_func(trim(substr($cma_info['thumb_field'], 5)), array('id' => $content_id), false);
$image_url = call_user_func(trim(substr($cma_info['thumb_field'], 5)), array('id' => $content_id), $row);
} else {
if ($content_type === 'image') {
if ($content_type === 'image') { // FUDGE (we don't actually want thumb in this case, we want full image)
$image_url = $row['url'];
// FUDGE
} else {
$image_url = $row[$cma_info['thumb_field']];
}
......
......@@ -57,7 +57,7 @@ class Hook_content_meta_aware_catalogue_entry
'title_field' => 'CALL: generate_catalogue_entry_title',
'title_field_dereference' => false,
'description_field' => null,
'thumb_field' => 'CALL: generate_catalogue_thumb_field',
'thumb_field' => 'CALL: generate_catalogue_entry_thumb_url',
'thumb_field_is_theme_image' => false,
'alternate_icon_theme_image' => null,
......@@ -176,12 +176,13 @@ function generate_catalogue_entry_title($url_parts, $resource_fs_style = false)
}
/**
* Find a catalogue entry thumbnail.
* Find an entry thumbnail.
*
* @param array $url_parts The URL parts to search from.
* @return string The field title.
* @param array $url_parts The URL parts to search from
* @param array $row Database row of entry
* @return string The thumbnail URL
*/
function generate_catalogue_thumb_field($url_parts)
function generate_catalogue_entry_thumb_url($url_parts, $row)
{
$unique_key_num = mixed();
......
......@@ -56,8 +56,8 @@ class Hook_content_meta_aware_news_category
'title_field' => 'nc_title',
'title_field_dereference' => true,
'description_field' => null,
'thumb_field' => 'nc_img',
'thumb_field_is_theme_image' => true,
'thumb_field' => 'CALL: generate_news_category_thumb_url',
'thumb_field_is_theme_image' => false,
'alternate_icon_theme_image' => null,
'view_page_link_pattern' => '_SEARCH:news:browse:_WILD',
......@@ -127,3 +127,16 @@ class Hook_content_meta_aware_news_category
return render_news_category_box($row, $zone, $give_context, $attach_to_url_filter, null, $guid);
}
}
/**
* Find an entry thumbnail.
*
* @param array $url_parts The URL parts to search from
* @param array $row Database row of entry
* @return string The thumbnail URL
*/
function generate_news_category_thumb_url($url_parts, $row)
{
require_code('news');
return get_news_category_image_url($row['nc_img']);
}
......@@ -874,7 +874,7 @@ abstract class Hook_sitemap_content extends Hook_sitemap_base
$this->_find_theme_image($row, $struct);
} else {
if (strpos($cma_info['thumb_field'], 'CALL:') !== false) {
$struct['extra_meta']['image'] = call_user_func(trim(substr($cma_info['thumb_field'], 5)), array('id' => $content_id), false);
$struct['extra_meta']['image'] = call_user_func(trim(substr($cma_info['thumb_field'], 5)), array('id' => $content_id), $row);
} else {
$struct['extra_meta']['image'] = $row[$cma_info['thumb_field']];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment