我正在尝试使用 Drupal 7 来管理 iOS 应用程序的内容。我可以设置 Drupal 来创建视网膜 (@2x) 大小和非视网膜大小的图像。与其更新应用程序以从不同的路径获取 @2x 图像,我想尽可能使用 mod rewrite 来提供来自不同文件夹的 @2x 图像。
例如,非视网膜图像的路径是:large
/sites/default/files/styles//public/flyers/OfficialSchedule.jpg?itok=qGpDKWpr
我希望 OfficialSchedule@2x.jpg 的请求来自:/sites/default/files/styles/ retina
/public/flyers/OfficialSchedule.jpg?itok=qGpDKWpr
这可能吗?
结果:感谢@jerdiggity
我必须$conf['image_allow_insecure_derivatives'] = TRUE;
为 Drupal 7.20 及更高版本添加到我的设置文件中,以允许在不添加令牌值的情况下请求图像。
# NOTES: Check the file name to see if it matches the @2x pattern:
RewriteCond %{REQUEST_FILENAME} ^(.*)(@2x\.\w+)$ [NC]
# NOTES: This may or may not be necessary, depending on your desired results (uncomment if so):
RewriteCond %{REQUEST_URI} ^(/sites/default/files/styles/regular/public/flyer/) [NC]
# NOTES: Rewrite everything with @2x, but don't rewrite requests to the /sites/default/files/styles/retina/public/flyer/ directory (duplicate rewrites)
RewriteCond %{REQUEST_URI} !^(/sites/default/files/styles/retina/public/flyer/) [NC]
RewriteRule ([^/]*)@2x\.(\w+) /sites/default/files/styles/retina/public/flyer/$1\.$2 [L,R=301]