FriendsOfFlarum / upload

The file upload extension with insane intelligence for your Flarum forum.
https://discuss.flarum.org/d/4154
MIT License
176 stars 95 forks source link

Bytedance ImageX Adapter #280

Closed ExerciseBook closed 3 years ago

ExerciseBook commented 3 years ago

Fixes #0000

Changes proposed in this pull request:

To add the ImageX adapter to fof-upload.

Reviewers should focus on:

Screenshot Admin Admin

Upload image file without setting template. We can see that there is no template ID at the end of the URL. Upload image file without setting template.

Upload image file with template setting. We can see that there is a template ID at the end of the URL. Upload image file with template setting.

Upload a non-image file but with template setting on. Upload a non-image file but with template setting on.

    protected function generateUrl(File $file)
    {
        $type = mb_strtolower($file->type);
        $path = $file->getAttribute('path');
        $template = $this->arrConfig["template"];

        if (Str::startsWith($type, "image/") && $template) {  // Check is image file or not.
            $url = '//' . $this->config->domain . '/' . $this->uriPrefix . '/' . $path . '~' . $template . '.image';
        } else {
            $url = '//' . $this->config->domain . '/' . $this->uriPrefix . '/' . $path;
        }
        $file->url = $url;
    }

Confirmed

Required changes:

None

luceos commented 3 years ago

Hi there and thank you for suggesting this upload adapter for fof/upload.

In order to keep this extension maintainable with the few number of people currently involved with it, we do not accept pull requests or feature requests for new upload adapters. The reason for this is that we would need to test the adapter on each upgrade of Flarum, plus whenever changes occur on this API of the upload service.

As a small team maintaining many extensions isn't always easy. That's why we try to reduce the workload by making clear choices on what we do and don't support .

The best option you have is to (have someone) create a completely new extension that registers the additional upload adapter. The maintenance of that extension is then dispersed away from our team. The best way to add your adapter is by listening to the Collecting event using the Flarum\Extend\Event extender.

If you have any questions about the implementation, feel free to open a discussion on the dev tag on discuss.

Thank you for your understanding.

ExerciseBook commented 2 years ago

https://github.com/ExerciseBook/fof-upload-imagex

A fof-upload extension was uploaded to packagist.

Thanks for your review @luceos .

This is a really late update for this pull request.

luceos commented 2 years ago

That's amazing @ExerciseBook 👍