Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Warning: foreach() argument must be of type array|object, bool given in UrlHelper.php on line 103 #131

Open
faganer opened this issue Oct 25, 2023 · 1 comment

Comments

@faganer
Copy link

faganer commented Oct 25, 2023

PHP Warning: foreach() argument must be of type array|object, bool given in UrlHelper.php on line 103

@TD-CLJI
Copy link

TD-CLJI commented Nov 3, 2024

将UrlHelper.php中的报错部分替换为下面的代码即可:
` /**

  • 将图片 Srcsets Url 替换为 OSS Url

  • @param $sources

  • @return mixed
    */
    public function replaceImgSrcsetUrl($sources)
    {
    // 检查 $sources 是否为数组
    if (!is_array($sources)) {
    return $sources;
    }

    // 遍历每个源
    foreach ($sources as $k => $source) {
    if (is_array($source) && isset($source['url']) && !$this->is_excluded($source['url'])) {
    $sources[$k]['url'] = str_replace($this->wpBaseUrl, $this->ossBaseUrl, $source['url']);

         if (Config::$sourceImgProtect && (false === strstr($sources[$k]['url'], Config::$customSeparator))) {
             $sources[$k]['url'] = $this->aliImageStyle($sources[$k]['url'], 'full');
         }
        
     }
     $sources[$k]['url'] = $this->sign_url($sources[$k]['url']);
    

    }
    return $sources;
    }`
    修复版插件:https://github.com/TD-CLJI/aliyun-oss-new

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants