0

Drupal 7 を使用して iOS アプリのコンテンツを管理しようとしています。Drupal を設定して、網膜 (@2x) サイズと非網膜サイズの画像を作成できます。アプリを更新して別のパスから @2x 画像を取得するのではなく、可能であれば mod の書き換えを使用して、別のフォルダーから @2x 画像を提供したいと考えています。

たとえば、非 Retina 画像へのパスは次のとおりです。 /sites/default/files/styles/ large/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]
4

1 に答える 1

0

ファイルの場所への絶対パスを使用してそれを行うことができるはずです...

これは、サイトが次の場所にインストールされていることを前提としています/home/mydrupalsite

# NOTES: Check the file name to see if it matches the @2x pattern:
RewriteCond %{REQUEST_FILENAME} ^(.*)(@2x\.jpg)$ [NC]

# NOTES: This may or may not be necessary, depending on your desired results (uncomment if so):
# RewriteCond %{REQUEST_URI} ^(/sites/default/files/styles/large/public/flyers/) [NC]

# NOTES: Rewrite everything with @2x, but don't rewrite requests to the /sites/default/files/styles/retina/public/flyers/ directory (duplicate rewrites)
RewriteCond %{REQUEST_URI} !^(/sites/default/files/styles/retina/public/flyers/) [NC]
RewriteRule ^(.*)@2x\.jpg /home/mydrupalsite/sites/default/files/styles/retina/public/flyers/$1\.jpg [L,R=301]

それが役立つことを願っています... :)

于 2013-05-24T21:00:46.423 に答える