Skip to content

Imgur image URL is using the relative protocol #72

@Hari-Bonda

Description

@Hari-Bonda

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');
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions