Image Archives

wordpress_logo

Translate this page into English with Google Translate or Excite Translation

特定のカテゴリーの記事をサムネイルのようにリスト表示するのに wp-kougabu を使おうかと思っていましたが、僕の環境ではいろいろと大変そうだったので、プラグインを作ってみました。wp-kougabu と同じように、画像付きのアーカイブを作れます。

Image Archives は、設定した文字列でデータベースを検索し、検索にヒットした画像を表示します。表示した画像は、その画像が使われている記事のパーマリンクにリンクされます。記事のタイトルも表示されます。

設定次第で、記事をサムネイル表示の様にできます。

利点

  • カスタムフィールドや、画像の「説明」に何かを書き加える必要がない。
  • アップロード時に、ファイル名に何かの法則性さえ持たせておけば検索が楽。
  • 記事内の画像で最初にアップロードしたものや最後にアップロードしたものを表示することもできる。ソートされた画像のファイル名での最初と最後の画像の指定も可能。

僕はPHPにあまり詳しくないので、公開するのは結構不安なのですが、もし何か問題あれば教えてください。是非、こうした方がいいというアドバイスもお願いします。

Sample

現在バージョン 0.41 です。

更新点

0.40

  • 特に検索文字列を使わなくても、記事の中の画像を一つだけ表示できるようにしました。この機能は first_image_mode=on にすると使えます。初期設定では記事内の「最初」の画像を表示します。「最初」というのは、最初にアップロードされたという意味です。記事の中の画像の位置ではないので注意してください。もちろん image_order を使うと、一番最後にアップロードされた画像を表示できます。アップロードされた時間ではなく、画像のファイル名(post_title) でも並べ替えが可能です。

0.30

  • design = 4, 5 の追加。4,5の時のみ、jQueryを用いて表示します。
  • item という attribute を横のアイテム数という意味から、1ページに表示するアイテムの数という意味に変えた。横の列の数は「column」で定めることができます。

0.20

  • テンプレートタグ、 wp_image_archives() の追加。
  • attributesの追加。limit, date_format, date_show を追加した。
  • 新しいデザインの追加。全然使えないかも。
  • term_id のデフォルト値を 1 にした。
  • class名を変更。
  • その他コードの修正。

ダウンロード

WordPress Plugin Directory

WordPress 2.9.2 で動作確認済みです。WordPress の「プラグイン」メニューの「新規追加」で検索してインストールする場合、ダウンロードする必要はありません。

インストール

方法1

WordPress の「プラグイン」メニューの「新規追加」から追加してください。ダウンロードしたzipをアップロードするか、検索で「Image Archives」を入れ、そこからインストールしてください。

方法2

上のzipを解凍して WordPress の

wp-content/plugins

というのフォルダに、解凍してできた”image-archives”フォルダをまるごとアップロードします。その後、WordPressのプラグインの管理から、Image Archivesを有効化(「使用する」)してください。

使い方

記事の中に、

[ image_archives ]

を追加します。image_archivesの両端の空白はいりません。[ima---hives]というように空白はいりません。さらに、attributes を設定します。必要な attributes だけを書いてください。

[ image_archives term_id=? ordered_by=? order=? str=? limit=? size=? design=? item=? column=? date_format=? date_show=? ]

例えば、下のような感じになります。

[ image_archives term_id=5 str=%_thumbnail limit=0,30 size=thumbnail design=2 item=5 date_show=on ]

または、PHP Codeの中で、

wp_image_archives ();

と書きます。この時、attributes の書き方は、

wp_image_archives ('term_id=3&limit=0,30&date_show=on');

の様にします。

attributes のデフォルトの値は下のようになっています。上のようにして attributes を設定しないとデフォルトの値が使われます。しかし、デフォルトの値では多くの場合画像が検索にヒットしないでしょう。特に term_id と str は設定しないとなりません。

もし上のような煩わしい設定なしに使ってみたい人は、first_image_mode を on にして、 term_id だけを設定してみてください。この時、初期設定では記事の中でアップロードされた画像の中で一番古い画像を表示します。つまり、一番最初にアップロードされた画像を表示します。記事の中の一番上にある画像ではないので注意してください。画像をファイル名でソートして、一番上に来たものを表示したい時、image_order_by=title としてください。ソートした時に一番下に来るものも表示できます。この様にしたい時、image_order=DESC としてください。一番最後にアップロードした画像を表示する時にも使えます。

first_image_mode= off
image_order_by	= date
image_order	= ASC
term_id		= 1
order_by	= title
order		= ASC
str			= %
limit		= 0,50
size		= medium
design		= 2
item		= 9
column		= 3
date_format	= Y-m-d
date_show	= off
title_show	= on
  • first_image_mode は記事内の画像を検索し、それを1つの記事に対して1つの画像を表示するモードです。画像の検索の設定は下の attributes できます。
  • image_order_by は first_image_mode が on の時のみに効果があります。どの項目に従ってソートをするか選択できます。datetitle を選べます。title というのは画像のファイル名だと思ってください。Database では post_title です。これはWordPressの管理画面の「メディア」から変更することも可能です。
  • image_order も first_image_mode が on の時のみに効果があります。上のソート方法を昇順か降順か選択できます。ASCDESC を入れてください。
  • term_id はタグやカテゴリーの数字のIDです。複数選択可能です。その時は、コンマで区切ってください。term_id=1,3,7 のようにしてください。
  • order_by はどの項目で並べるかです。title または date が選べます。
  • order は実際の並べる順番です。昇順と降順が選べます。ASCDESC を選べます。
  • str は検索文字列です。SQLのLIKE条件の文字列を書きます。(参考サイト) アップロードした画像のファイル名にヒットするように設定します。デフォルトでは “%” になっています。設定した term_id に含まれる画像が全て表示されます。特定の画像にしたい場合、拡張子を除いた名前が post_title(メディアライブラリのファイル、タイトルと同じです。) に格納されているので、拡張子を除くファイル名を指定してください。例えば、アップロードした画像が、「good-foods-for-your-health-1」の時、”str=good%”、”str=good-foods%”、”str=”%health%” などとすると検索にヒットします。
  • limit は表示する画像の数の制限です。’始めの数字,終わりの数字’ という様に指定します。’limit=0,30′ という感じに使います。また、’limit=20,50′ の様に、始めの数字は ’0′ で無くてもかまいません。
  • size は表示する画像のサイズです。アップロードした画像は WordPress によって縮小されるのでそれを用います。thumbnail, medium, large, full を選べます。
  • design は、出力のデザインです。ぱっと思いついたデザインですが、1 から 5 を選べます。4,5については、jQuery を用いて表示しますので、JavaScript が有効である必要があります。
  • column は design=2,4,5 の時に有効で、テーブルの列数、つまり一行に表示する画像の数です。念のため 1以上100以下 に限定しています。
  • item は1ページ(Section)に表示する画像の数です。design=4,5 の時に有効です。
  • date_format は日付を表示する際のフォーマットです。これは PHP.net date を参照してください。
  • date_show は日付を表示するかどうかの設定です。onoff にしてください。
  • title_show は記事のタイトルを表示するかどうかの設定です。onoff にしてください。

CSSでデザインをいじってください。table に class=”img_arc” を付けてあります。div については、画像を表示する前の div には class=”img_arc_img” を、テキストの前の div には、class=”img_arc_text” にしています。また、日付を表示する div は class=”img_arc_date” にしてます。

table.img_arc {
	border: 0 none;
	margin: 0;
}

div.img_arc_text a {
	text-decoration: none;
}

などとしてください。また、design=4,5 で jQuery を使った時のCSSに関しては、jQuery UI の AccordionTabs を参照してください。

注意事項

  • 画像は記事に添付されている必要があります。
  • パーマリンク先の記事は「公開済み」である必要があります。

デザイン

このデザインは古いバージョンのものです。参考程度にしてください。


同じタグを持つ記事

この記事に関連する記事

Comments: 27

Anonymous より:

お世話になります。
現在製作中のサイトがあり、そこで画像のサムネイルをカテゴリ別に表示させたいと考えています。
そこでこのプラグインに辿り着きました。

≪イメージ≫
■今後放送予定
番組サムネイル
■放送終了
番組サムネイル
↑↑↑↑↑
このようにしたく、
放送中=投稿のカテゴリは1(?cat=1″)
終了=投稿のカテゴリは2(?cat=2″)
このようにカテゴリ分けを行っている場合の方法を
宜しければ教えていただけないでしょうか?

coppola より:

上の「使い方」を見て分からない箇所を教えてください。
カテゴリーの指定方法が分からないという事でしょうか。2つのカテゴリーを分けて表示したいのでしょうか。記事の画像が表示されないのでしょうか。また、試した設定方法を書き込んでください。

匿名 より:

すみません。
操作がようやく分かりました。

一覧としてサムネイル画像を4つ並べたいのですが、
size=thumbnail
を選択した際のサムネイル画像のサイズを小さくしたい場合は
どのようにすれば良いのでしょうか?

それと
サムネイル画像をkougabuのようなデザインにしていただくことは可能でしょうか?
画像がテーブルで囲まれており、
その下に文字が折り返す表示になっています。
http://fmspot.jp/program/

宜しくお願いいたします。

Grrambo より:

Hey there. I can’t understand your website, but I downloaded your plugin because it appeared to be exactly what I was looking for. I wanted some way for people to search all my previous posts easily and by photo.

I couldn’t seem to get it to work. When I placed it in a wordpress page it gave me the error ” Query Error. Your ‘str’(search strings) may be wrong or your input ‘term_id’ don’t exsit, or ‘limit’ may be wrong. ”

Am I doing something wrong? Is there an easy fix? I’m not good with code but I’d really appreciate if you can e-mail me back and help me out. If you need any english translations I will be happy to help. Once this plugin is working it will be huge! There is nothing else like it!
Thanks again

coppola より:

Excite translation of this site helps you a little. Please check it. http://www.excite-webtl.jp/world/english/web/?wb_url=http%3A%2F%2Fif-music.be%2F2009%2F11%2F10%2Fimage-archives%2F&wb_lp=JAEN&wb_dis=2&wb_submit=+%96%7C+%96%F3+
And WordPress Plugin Directory of this plugin also helps you a little. http://wordpress.org/extend/plugins/image-archives/

The error “Query Error. Your ‘str’(search strings) may be wrong or your input ‘term_id’ don’t exist, or ‘limit’ may be wrong.” means “Searching your database was done, but any images were not found.”. So you need to configure some attributes.

First, your installation of this plugin was successfully done. So in order to get it work, you need at least to configure the “str”(search string) attribute and “term_id” attribute. This plugin does NOT automatically show the images of your posts.

“str” must be a part of the file name of images you uploaded. For example, if you posted a article that has an image named “good-foods-for-your-health-1″, you need to configure “str=good%” or “str=good-foods%” or “str=%health%” or like that. “%” means wildcard, so if you configure “str=%”, all images of your posts within “term_id” appear.

“term_id” must be the category id of your wordpress. If you don’t know the id of your wordpress, login your wordpress, and go to categories page. You can see the category id by the link of your category. If you want to set some ids, use “,”. For example “term_id=2,5,8″.

From your comment, I understood the difficulty of “str”, I will update this plugin and default of “str” will be set to “str=%”.

If you can’t understand my sentences, please tell me the sentences. :)

coppola より:

(Instead of Grrambo, I submitted this comment)
Grrambo says:

Thank you very much for the reply and helping!

So far, I have put in the newest information and here is what I have
so far:

[image_archives
term_id
=
3,1001,170,1120,4,5,6,568,7,283,8,1428,432,113,41,152,224,631,798,11,214,12,1566,13,102,100,860,120,148,14,360,15,92,141,9,10
ordered_by=date order=ASC str=% limit=0,30 size=thumbnail design=4
item=5 column=3 date_format=Y-m-d date_show=off]

But i seem to still be getting this error:

Query Error? Searching your database was done, but any images were not
found. Your ‘str’(search strings) may be wrong or your input ‘term_id’
don’t exist, or ‘limit’ may be wrong.

I’m not sure what else to try. But I really hope I can get this
working! If it does I’d like to help you set up an english page and
some graphics for this wordpress plugin if you like, to show my
appreciation. I really do think this will be quite popular once the
kinks are sorted out.
Thanks again!

coppola より:

Thanks for your reply.

Although I tried your code in my wordpress, the error doesn’t appear,
I noticed that your code includes extra whitespaces and returns, so it might cause the error.

Please try following code. (copy&paste to your article.)
###########################################
[image_archives term_id=3,1001,170,1120,4,5,6,568,7,283,8,1428,432,113,41,152,224,631,798,11,214,12,1566,13,102,100,860,120,148,14,360,15,92,141,9,10 ordered_by=date order=ASC str=% limit=0,30 size=thumbnail design=4 item=5 column=3 date_format=Y-m-d date_show=off]
###########################################

If above code causes the error, please reduce the amount of “term_id”. For example, only “term_id=3″.
And write only the necessary attributes. For confirmation, I wrote the code below.
###########################################
[image_archives term_id=3 str=%]
###########################################

If above code also causes the error, please make sure your term_id(category or tag IDs) is correct.
If the error still be caused, I don’t know what causes the error. I’ll need to examine your database and wordpress.

Grrambo より:

Thank you very very much.
That seems to do the trick. I’ll have fun playing around with it getting the settings just right.

One thing I noticed is that if an item appears in more than one category the photo appears several times, is there any way to have a photo appear only once?

Also, if you need anything from me, full English instructions, translations, graphics, etc. I’d be happy to help. Once this plugin has a nice looking landing page I’m sure it will quickly become a popular plugin on wordpress. So if done the right way it could really drive a ton of traffic to your site.

Let me know if you need a hand.

coppola より:

I’m glad to have helped you.

I changed that the image of the post appears several times. Please update Image Archives to version 0.34 and try again.

I don’t have enough time to work at this plugin and this site. I’m thankful that you said so, but even if you make the instruction page of this plugin, I can’t link the page soon. If you were kind enough to make the English instruction page, please submit a comment in the plugin page or this page. If you do so, maybe anyone can see the instruction page. I’ll very thank you for your doing so.

I think that WordPress will have this feature in the future. Even now WordPress 2.9 has ‘post image’ feature. This feature is a little bother to use, but in the future it’ll be easy to use.

Grrambo より:

Hello there. I have a few more customizing questions. I really appreciate you helping me out.

Is there any way to have it just grab the first image from each post, rather than every single image that is the site?

Is there any way to just have the thumbnail photo showing and NOT the title of the post?

That’s again for all the help and the great plugin.

coppola より:

The easiest way to grab the first image, search the database with appropriate strings. The ‘first’ image has several means. The ‘first’ uploaded image in the post, the ‘first’ file name of the images in the post, the ‘first’ located image in the post. So, I think an easy way to show the first image is to add the special strings to the image file name that you want to show. For example, if you uploaded health-1, health-2, health-3, health-thumb, you can configure ‘str=%-thumb’. Even after you upload image files, you can change the file name.

I updated this plugin to version 0.40. I added the first_image_mode. Please try to use this. Without configure the search strings you can search a image in a post, and show a image per post. This feature can show the first uploaded image per post. And if you want to show the first image that is sorted by filename, configure image_order_by=title. And if you want to show the latest image, configure image_order=DESC. But please be careful, the first image does NOT mean the first located image in the post.

As for the way not to show the title of the post, use CSS. For example in design=5,

div.img_arc_text p.img_arc {
visibility: hidden;
}

Grrambo より:

Thanks again for your help, the plugin is working great and looking very very good.

Just that one last question, I know you are busy, so no rush, but is there any way to just have the thumbnail photo showing and NOT the title of the post next to or below the image?

Thanks again, seriously, if you need anything, or any graphic work or marketing advice or advertising in the future, feel free to let me know. I owe you. You’ve been great.

coppola より:

As for the way not to show the title of the post, use CSS(Cascading Style Sheets). For example in design=5,

div.img_arc_text p.img_arc {
visibility: hidden;
}

Do you mean that you want to erase the title of the post from the output source? Or you don’t want to use CSS?

I’m very glad that you said so. If I need your help, I’ll contact you. Very thank you.

coppola より:

I updated this plugin to version 0.41. I added ‘title_show’ attribute. Please use this attribute. If you use this, you needn’t use CSS not to show the titles. And I changed some output tags. So if you use CSS,

div.img_arc_text {
visibility: hidden;
}

This CSS can change the title to be not showed. But Configuring ‘title_show’ attribute is easy way not to show the titles.

Grrambo より:

Thanks so much Coppola. Feel free to see your excellent plugin in action at:
http://www.onemoregadget.com/browse-all/

I will post something for you shortly.

coppola より:

Nice page! I’m really glad to see anyone use my plugin. Thanks!

Grrambo より:

Description

Image Archives is a wordpress plugin that displays images from your published posts with a permalink back to the post that the image is connected to. It can also be used as a complete visual archive or gallery archive with several customizable settings.

NOTE

• The images that you want to show will be attached to the post they were published in.
• In order to link to the permalink of a post, the post must first be “published.”

Thanks, great job!

coppola より:

Thanks! I’ll change the description of the plugin directory of this plugin.
I was afraid that the description of this plugin cannot be understood.

becca より:

Thanks for this great plugin!
Have a request – Can it be made to have basic pagination?

E.g. Show 20 images in 5 pages (4 on each page)
Page 1 of 1

coppola より:

Thanks for your comment.

I’ll add your requested function to this plug-in in the future, but now I’m very sorry, I have no time.

lortnoc より:

first of all thanks a lot for you plugin.. ;)

was really important to my photographic project..

but right now i have a problem. at the beginning you plug in was working great.. as you can see on this page: http://cityburns.com/stories

until now the posts just has 3 digits on their id, like this one is “926″: http://cityburns.com/stories/926

now, the last post has 4 digits on id, like this one is “1071″: http://cityburns.com/stories/1071 and, i think because of this, doesn’t appear on the image archive group..

can you please help me to fix this problem, with a new version of plug in or some instrutions to edit the plug in…

i will be really thankful for your help..

best regards, from Lisbon..
lortnoc!

coppola より:

I’m very sorry for my late reply.

I couldn’t see your link page, but I think you have been misunderstanding. You have to fill up “term_id” with the IDs of categories or tags. So even if you fill up “term_id” with a page id, the images of the page don’t appear. I think the 3 digits “926″ exists in your categories or tags.

lortnoc より:

ah, maybe this caqn help. on the page i have this code: [image_archives first_image_mode=on image_order_by=title image_order=ASC term_id=10 order_by=date order=DESC str=% limit=0,100 size=medium design=2 item=16 column=4 date_format=Y/m/d date_show=off title_show=off]

thanks for your time one more time.. ;)

lortnoc より:

ok. forgot. i found the error. tahnks again.

coppola より:

I’m very sorry for my late comment.
I tried the code above, but any problems didn’t occurred.

Leave a Comment





Return to Top