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

发布于 2024-11-05 12:24:03 字数 1100 浏览 4 评论 0原文

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

//来自模块的代码

$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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

秋风の叶未落 2024-11-12 12:24:03

你不能只使用 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']); ?>

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:

<?php print str_replace("www.google.com", "www.myhost.com", $content['current']['icon']); ?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文