将默认图像路径替换为自定义图像路径
我真正想做的就是用我的路径替换谷歌的路径。
//来自模块的代码
$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>
All i really want to do is replace google's path with mine.
//code from module
$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,
);
//code from tpl.php
<div class="weather-icon float-left">
// <?php print $content['current']['icon']; ?>
<?php print $base_url; ?>
<?php print $content['current']['custompath']; ?>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你不能只使用 str_replace 吗?例如,如果现在显示 http://www.google.com/images/icon.png 并且您需要 http://www.myhost.com/images/icon.png:
can't you just use a str_replace? For example if it now says http://www.google.com/images/icon.png and you need http://www.myhost.com/images/icon.png: