Osclass rss feed
on :May 3, 2023, 10:31 pm #696
Pls how can I change image url in osclass feed.. e.g from https//-----/feed.. it fetches images url like this: https://-----/oc-content/uploads/17/12606_thumbnail.jpg
How can I make it to fetch original image. E.g https://----/oc-content/uploads/17/12606_original.jpg
I will appreciate if someone can help..
Re: Osclass rss feed
on :May 4, 2023, 6:00 pm #697
Try this in your functions.php file from your theme or index.php from a plugin.
Or you can create a special plugin only for this, so you don't overwrite these changes on the theme/plugin update.
function feedHookOriginalImage() {
$p_sFeed = Params::existParam('sFeed');
if ($p_sFeed) {
if ($p_sFeed == '' || $p_sFeed == 'rss') {
// FEED REQUESTED!
header('Content-type: text/xml; charset=utf-8');
$feed = new RSSFeed;
$feed->setTitle(__('Latest listings added') . ' - ' . osc_page_title());
$feed->setLink(osc_base_url());
$feed->setDescription(__('Latest listings added in') . ' ' . osc_page_title());
if (osc_count_items() > 0) {
while (osc_has_items()) {
try {
$itemArray = array(
'title' => osc_item_title(),
'link' => htmlentities(osc_item_url(), ENT_COMPAT, 'UTF-8'),
'description' => osc_item_description(),
'country' => osc_item_country(),
'region' => osc_item_region(),
'city' => osc_item_city(),
'city_area' => osc_item_city_area(),
'category' => osc_item_category(),
'dt_pub_date' => osc_item_pub_date()
);
} catch (Exception $e) {
}
try {
if (osc_count_item_resources() > 0) {
try {
osc_has_item_resources();
} catch (Exception $e) {
}
try {
$itemArray['image'] = array(
//the only change in the original code "osc_resource_original_url()"
'url' => htmlentities(osc_resource_original_url(), ENT_COMPAT, 'UTF-8'),
'title' => osc_item_title(),
'link' => htmlentities(osc_item_url(), ENT_COMPAT, 'UTF-8')
);
} catch (Exception $e) {
}
}
} catch (Exception $e) {
}
$feed->addItem($itemArray);
}
}
osc_run_hook('feed', $feed);
$feed->dumpXML();
} else {
$aItems = View::newInstance()->_get('items');
osc_run_hook('feed_' . $p_sFeed, $aItems);
}
exit();
}
}
osc_add_hook('after_search', 'feedHookOriginalImage');