ホームページ  >  記事  >  バックエンド開発  >  アダプティブ画像 PHP 画像アダプテーション クラス

アダプティブ画像 PHP 画像アダプテーション クラス

WBOY
WBOYオリジナル
2016-06-20 13:02:031139ブラウズ

アダプティブ イメージは、画像を小型モバイル デバイスに転送する PHP で書かれたツールです。アプリケーション組み込みソリューションは、追加の画像変更を必要とせずに、デバイスの画面サイズに応じて画像を自動的に作成、キャプチャ、送信します。

使用方法

1. 画像フォルダーに .htaccess ファイルを作成します

<IfModule mod_rewrite.c><br /> Options +FollowSymlinks<br /> RewriteEngine On<br /> # Adaptive-Images -----------------------------------------------------------------------------------<br /> # Add any directories you wish to omit from the Adaptive-Images process on a new line, as follows:<br /> # RewriteCond %{REQUEST_URI} !ignore-this-directory<br /> # RewriteCond %{REQUEST_URI} !and-ignore-this-directory-too<br /> RewriteCond %{REQUEST_URI} !assets<br /> # Send any GIF, JPG, or PNG request that IS NOT stored inside one of the above directories<br /> # to adaptive-images.php so we can select appropriately sized versions<br /> RewriteRule .(?:jpe?g|gif|png)$ adaptive-images.php<br /> # END Adaptive-Images -------------------------------------------------------------------------------<br /></IfModule>

2. アダプティブ画像を必要とする各 Web ページに次の JS スクリプトをコピーします。ヘッダー

<script>document.cookie='resolution='+Math.max(screen.width,screen.height)+'; path=/';</script>

3. HTML コード





test

<script>document.cookie='resolution='+Math.max(screen.width,screen.height)+'; path=/';</script>



Example in action





プロジェクトアドレス: http://adaptive-images.com/


声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。