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

Add a URL suffix setting #298

Open
alexkuang0 opened this issue Sep 11, 2021 · 0 comments
Open

Add a URL suffix setting #298

alexkuang0 opened this issue Sep 11, 2021 · 0 comments

Comments

@alexkuang0
Copy link

Feature Request

Is your feature request related to a problem? Please describe.

Add a URL suffix option in settings. So that the URLs of uploaded files can be appended some more contents like query strings.

In my case, I use Alibaba Cloud OSS, an S3-compatible service. It provides an image processing function, in which I can define image processing rules (to add watermark, compress, etc.) and append a query string like ?x-oss-process=style/<rule name> after the image URL to get a post-processed image. I can also serve processed images only and disable access to the original image.

For example, if I uploaded an image to OSS and get the URL https://static.my.site/image.jpg, I can use the URL https://static.my.site/image.jpg?x-oss-process=style/forum to apply a image processing rule named forum to the image. It also provides a shorter way to add that post-processing rule like this: https://static.my.site/image.jpg/forum.

Describe the solution you'd like

Add an option in the extension settings so I can set a suffix to the URLs in the database.

Describe alternatives you've considered

Since I am not familiar with setting up a development environment and fear of breaking things, I just changed the code manually in my installation.

In file vendor/fof/upload/src/Adapters/AwsS3.php:

...
protected function generateUrl(File $file)
{
	...

-	$file->url = sprintf('%s/%s', $cdnUrl, Arr::get($this->meta, 'path', $file->path));
+	$file->url = sprintf('%s/%s?x-oss-process=style/forum', $cdnUrl, Arr::get($this->meta, 'path', $file->path));
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant