将默认图像路径替换为自定义图像路径


replace default image path with custome image path

我真正想做的是用我的路径替换谷歌的路径。

来自模块的代码

$today = &$handler->current_conditions;
$condition = (string) $today->condition->attributes()->data;
$unit = google_weather_get_unit($convert_to);
$icon_src = (string) $today->icon->attributes()->data;
$content['current'] = array(
    'temp' => $convert_to == 'SI' ? (string) $today->temp_c->attributes()->data . $unit : (string) $today->temp_f->attributes()->data . $unit,
    'humidity' => (string) $today->humidity->attributes()->data,
    'icon' => theme('image', 'http://www.google.com' . $icon_src, $condition, $condition, NULL, FALSE),
    'condition' => $condition,
    'wind_condition' => (string) $today->wind_condition->attributes()->data,
    'custompath'=> $icon_src,
);

来自 TPL 的代码.php

<div class="weather-icon float-left">
   // <?php print $content['current']['icon']; ?>
     <?php print $base_url; ?>
     <?php print $content['current']['custompath']; ?>
</div>
你不能

只使用str_replace吗?例如,如果它现在显示 http://www.google.com/images/icon.png 并且您需要 http://www.myhost.com/images/icon.png:

<?php print str_replace("www.google.com", "www.myhost.com", $content['current']['icon']); ?>