core icon indicating copy to clipboard operation
core copied to clipboard

Added 'getImageCacheName' hook to allow modification of the cache name.

Open uvoelkel opened this issue 10 years ago • 6 comments

The 'getImageCacheName' hook allows modification of the image cache name. This could be useful to filter out filenames that might get blocked by Adblockers.

uvoelkel avatar May 03 '14 07:05 uvoelkel

What file names are blocked by ad blockers?

leofeyer avatar May 03 '14 17:05 leofeyer

I know that EasyList (German) has at least one rule that blocks everything with advert or advertising in the name which is kind of a problem if you are building a website for a company that sells online ads. And I would not be surprised if names like banner, tracker, etc.. would also be blocked.

uvoelkel avatar May 04 '14 13:05 uvoelkel

But if the original image name does not contain those keywords, the cached version will not either.

leofeyer avatar May 04 '14 17:05 leofeyer

I know. But how do I prevent the customer from using certain keywords when uploading files via the contao backend? I may be able to hook into the upload process and throw an error if certain keywords are used. But that would require me to know all the endangered keywords beforehand and it is kind of a pain for the customer not being able to use the actual product names for their product example images.

So my first instinct was to get rid of the original filename part in the cache path. The customer can use whatever filenames he wants. I don't have to maintain some sort of blacklist and Adblock is also happy.

I understand if this is too much of an edge case (happened to me for the first time in many years with the current project). But I thought I might give it a try anyway.

uvoelkel avatar May 05 '14 06:05 uvoelkel

how do I prevent the customer from using certain keywords when uploading files

Have you tried the postUpload hook?

leofeyer avatar May 05 '14 11:05 leofeyer

It was more like a rhetorical question ;) The problem is that i would still need to know what keywords to filter and it might confuse the user if he uploads a file "banner-ad-example.jpg" and the file gets renamed to something else. I don't want to restrict the user in his choice of filenames. I'd rather just rewrite the filenames in the frontend.

uvoelkel avatar May 05 '14 14:05 uvoelkel