
CQT_Fotolia_APIを生成します。
- define('FOTOLIA_API_KEY', 'apikey');
- define('FOTOLIA_ID', 'id');
- $fotolia = CQT_Fotolia::factory(FOTOLIA_API_KEY, FOTOLIA_ID);
指定したidの画像を取得します。
- $photos = $fotolia->getItems('18580260,9933855,error_value');
- $html = '';
- foreach ($photos as $photo) {
- $tr = '';
- foreach ($photo as $key => $value) {
- $tr .= sprintf('
- <tr>
- <th>%s</th>
- <td>%s</td>
- </tr>
- ',
- $key,
- $value
- );
- }
- $html .= '<table>' . $tr . '</table>';
- }
- echo $html;
| id | 18580260 |
|---|---|
| ex_affiliate_url_creator | http://jp.fotolia.com/p/117924/partner/201417048 |
| ex_affiliate_url_media | http://jp.fotolia.com/id/18580260/partner/201417048 |
| title | Young dancing woman |
| creator_name | George Mayer |
| creator_id | 117924 |
| creation_date | 2009-11-21 16:34:03.399564 |
| media_type_id | 1 |
| thumbnail_url | http://t1.ftcdn.net/jpg/00/18/58/02/110_F_18580260_OnPeYDbxlCPbOO4Nn2QWVvfoiOdevFj9.jpg |
| thumbnail_width | 110 |
| thumbnail_height | 110 |
| thumbnail_html_tag | ![]() |
| id | 9933855 |
|---|---|
| ex_affiliate_url_creator | http://jp.fotolia.com/p/17174/partner/201417048 |
| ex_affiliate_url_media | http://jp.fotolia.com/id/9933855/partner/201417048 |
| title | Young woman sitting on floor with a laptop |
| creator_name | Yuri Arcurs |
| creator_id | 17174 |
| creation_date | 2008-10-16 09:36:59.580849 |
| media_type_id | 1 |
| thumbnail_url | http://t1.ftcdn.net/jpg/00/09/93/38/110_F_9933855_MgAZrblBZCeFLPkbTueQLZkgSViTNPJZ.jpg |
| thumbnail_width | 93 |
| thumbnail_height | 110 |
| thumbnail_html_tag | ![]() |
| error | 1 |
|---|---|
| error_title | Missing Media ID |
| error_comment | The media ID is missing. Media ID is required for this method. |
画像の取得とHTML加工。Fotolia/tpl/standard/以下のテンプレートファイルが使用されます。
- echo $fotolia->render('standard', '18580260,10458789');
カルーセル形式で出力します。利用するページでjQuery、同梱のfotolia.cssとfotolia.jsを読み込んでください。 殴り書きなので、ブラウザによっては変になります。 愛用のライブラリなどあればそちらを利用したほうが良いです。
- $fotolia->setMediaSize('L');
- $fotolia->gallery('18580260,3792814,5668968,8889955,19268622,5689214,10674034,10458789');
- echo $fotolia->render('debug', '18580260,3792814,test');
| key | value |
|---|---|
| id | 18580260 |
| title | Young dancing woman |
| creator_name | George Mayer |
| creator_id | 117924 |
| creation_date | 2009-11-21 16:34:03.399564 |
| media_type_id | 1 |
| thumbnail_url | http://t1.ftcdn.net/jpg/00/18/58/02/400_F_18580260_OnPeYDbxlCPbOO4Nn2QWVvfoiOdevFj9.jpg |
| thumbnail_width | 400 |
| thumbnail_height | 400 |
| thumbnail_html_tag | ![]() |
| baseurl_home | http://jp.fotolia.com/ |
| baseurl_creator | http://jp.fotolia.com/p/ |
| baseurl_media | http://jp.fotolia.com/id/ |
| affiliate_path | partner |
| affiliate_url_home | http://jp.fotolia.com/partner/201417048 |
| affiliate_url_creator | http://jp.fotolia.com/p/117924/partner/201417048 |
| affiliate_url_media | http://jp.fotolia.com/id/18580260/partner/201417048 |
| id | 10458789 |
| title | Portrait of a woman |
| creator_name | ant236 |
| creator_id | 200702983 |
| creation_date | 2008-11-15 23:01:50.883379 |
| media_type_id | 1 |
| thumbnail_url | http://t2.ftcdn.net/jpg/00/10/45/87/400_F_10458789_oPuVz9yrOhfSI1bBxdTBjpu0civDskuX.jpg |
| thumbnail_width | 267 |
| thumbnail_height | 400 |
| thumbnail_html_tag | ![]() |
| baseurl_home | http://jp.fotolia.com/ |
| baseurl_creator | http://jp.fotolia.com/p/ |
| baseurl_media | http://jp.fotolia.com/id/ |
| affiliate_path | partner |
| affiliate_url_home | http://jp.fotolia.com/partner/201417048 |
| affiliate_url_creator | http://jp.fotolia.com/p/200702983/partner/201417048 |
| affiliate_url_media | http://jp.fotolia.com/id/10458789/partner/201417048 |
画像サイズの変更。()でS、M、Lまたは30、110、400を指定する。デフォルトはM
- $fotolia->setImageSize('S');
- $fotolia->render('standard', '18580260');
- $fotolia->setImageSize('M');
- $fotolia->render('standard', '18580260');
- $fotolia->setImageSize('L');
- $fotolia->render('standard', '18580260');
lib/standard | gallery | debug/以下が出力されるHTMLのテンプレートになります。element.htmlがlayout.htmlで囲まれる感じです。
layout.html
element.html
element.html
element.html
error.htmlは現在利用できません。
プログラムから渡されるデータは下記で参照できます。
| key | value |
|---|---|
| id | 18580260 |
| title | Young dancing woman |
| creator_name | George Mayer |
| creator_id | 117924 |
| creation_date | 2009-11-21 16:34:03.399564 |
| media_type_id | 1 |
| thumbnail_url | http://t1.ftcdn.net/jpg/00/18/58/02/400_F_18580260_OnPeYDbxlCPbOO4Nn2QWVvfoiOdevFj9.jpg |
| thumbnail_width | 400 |
| thumbnail_height | 400 |
| thumbnail_html_tag | ![]() |
| baseurl_home | http://jp.fotolia.com/ |
| baseurl_creator | http://jp.fotolia.com/p/ |
| baseurl_media | http://jp.fotolia.com/id/ |
| affiliate_path | partner |
| affiliate_url_home | http://jp.fotolia.com/partner/201417048 |
| affiliate_url_creator | http://jp.fotolia.com/p/117924/partner/201417048 |
| affiliate_url_media | http://jp.fotolia.com/id/18580260/partner/201417048 |
| メディアID | {{{ id }}} |
|---|---|
| 画像のタイトル | {{{ title }}} |
| 作者名 | {{{ creator_name }}} |
| 作者ID | {{{ creator_id }}} |
| 作成日 | {{{ creation_date }}} |
| メディアID | {{{ media_type_id }}} |
| 画像のURL | {{{ thumbnail_url }}} |
| 画像の横幅 | {{{ thumbnail_width }}} |
| 画像の縦 | {{{ thumbnail_height }}} |
| imgタグ | {{{ thumbnail_html_tag }}} |
| fotoliaのHOMEのURL | {{{ baseurl_home }}} |
| 作者ページへのURL | {{{ baseurl_creator }}} |
| 写真(メディア)ページのURL | {{{ baseurl_media }}} |
| affiliate_path | {{{ affiliate_path }}} |
| fotoliaのHOMEのアフィリエイトURL | {{{ affiliate_url_home }}} |
| 作者ページのアフィリエイトURL | {{{ affiliate_url_creator }}} |
| 写真(メディア)ページのアフィリエイトURL | {{{ affiliate_url_media }}} |
結果をキャッシュします。けっこう重いのでこれを利用しないと使いものになりません。