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

Imgur image URL is using the relative protocol #72

Open
Hari-Bonda opened this issue Mar 15, 2022 · 0 comments
Open

Imgur image URL is using the relative protocol #72

Hari-Bonda opened this issue Mar 15, 2022 · 0 comments

Comments

@Hari-Bonda
Copy link

image

https://discuss.flarum.org/d/18316-flarum-seo/498

public function setImageFromContent($content = null)
    {
        // Check post content is not empty
        if($content !== null) {
            // Read Post content and filter image url
            $pattern = '/(?<=src=")((http.*?\.)(jpe?g|png|[tg]iff?|svg))(?=")/';

            // Use image from post for social media og:image
            if (preg_match_all($pattern, $content, $matches) && count($matches) > 0) {
                $contentImage = $matches[0][0];

                if ($contentImage !== null) {
                    $this->setImage($contentImage);
                    return $this;
                }
            }
        }

        return $this;
    }

To solve this, remove preg replace

file: /vendor/fof/upload/src/Adapters/Imgur.php
// successful upload, let's get the generated URL
        if ($response->getStatusCode() == 200) {
            $meta = Arr::get(json_decode($response->getBody(), true), 'data', []);

            $link = Arr::get($meta, 'link');

            $file->url = $link; //preg_replace('/^https?:/', null, $link);
            $file->remote_id = Arr::get($meta, 'id');
        }
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

1 participant