{"action":"opened","issue":{"url":"https://api.github.com/repos/markevans/dragonfly/issues/392","labels_url":"https://api.github.com/repos/markevans/dragonfly/issues/392/labels{/name}","comments_url":"https://api.github.com/repos/markevans/dragonfly/issues/392/comments","events_url":"https://api.github.com/repos/markevans/dragonfly/issues/392/events","html_url":"https://github.com/markevans/dragonfly/issues/392","id":64129584,"number":392,"title":"Automatically serves WebP when browser has support","user":{"login":"loureirorg","id":371973,"avatar_url":"https://avatars.githubusercontent.com/u/371973?v=3","gravatar_id":"","url":"https://api.github.com/users/loureirorg","html_url":"https://github.com/loureirorg","followers_url":"https://api.github.com/users/loureirorg/followers","following_url":"https://api.github.com/users/loureirorg/following{/other_user}","gists_url":"https://api.github.com/users/loureirorg/gists{/gist_id}","starred_url":"https://api.github.com/users/loureirorg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loureirorg/subscriptions","organizations_url":"https://api.github.com/users/loureirorg/orgs","repos_url":"https://api.github.com/users/loureirorg/repos","events_url":"https://api.github.com/users/loureirorg/events{/privacy}","received_events_url":"https://api.github.com/users/loureirorg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-24T23:54:21Z","updated_at":"2015-03-24T23:54:21Z","closed_at":null,"body":"How do I force DragonFly convert to and serve WebP when the browser has support? WebP images are about 25% lower than jpg, so its a quite appealing idea ;) And I want to do this on-the-fly, not when saving the image.\r\n\r\nMy problem its not to discover whenever a browser has support or not, but create a callback that generates a new version and serve it.\r\n\r\nI'm trying to use `before_serve` (http://markevans.github.io/dragonfly/configuration/) to do the job. \r\n\r\n```ruby\r\n# config/initilizers/dragonfly.rb\r\nDragonfly.app.configure do\r\n...\r\n  before_serve do |job, env|\r\n    if job.content.mime_type != \"image/webp\"\r\n      job.content.shell_update do |old_path, new_path|\r\n        \"/usr/bin/cwebp #{old_path} -o -\"\r\n      end\r\n    end\r\n  end\r\nend\r\n```\r\n\r\nThe problem is: job.content is always empty. My guess is because its called before the steps be processed. So, how do I get the file name of the served file right before it be served?"}}