Wordpress custom post types and MANY images
I will be using Wordpress as a CMS with custom post types. Each "post" is a product and will have 20-60 images in 3 different sizes (60-180 total images per product).
What's the best way to link the images to the post?
I'm thinking about storing them o开发者_运维百科n Amazon S3 and recording the URLs in custom meta tags, but I want to make sure I do it in a way that its easy to retrieve.
The WordPress has a built-in media library which has hooks that relate images to specific posts (products in your case). Given that a solid API exists for this, you may want to start there.
Helpful functions to look into are:
wp_insert_attachment
wp_delete_attachment
wp_get_attachment_image_src
wp_get_attachment_metadata
Update: To be more specific for this project, also be sure to look into add_image_size
which allows you to define various thumbnail sizes which your posts can use. In other words, upload one large image and WP will automatically generate the rest. Mark J. of the WP team made a good writeup of the feature back wen 2.9 was released.
As for the S3, that definitely isn't a bad idea either, but keep WP as being your core source of data. Perhaps you can use a back-end process to move them to S3 and then update the attachment's metadata. When you render the post, check to see if a S3 URI exists, otherwise default to a local image.
(Disclosure: I'm not very familiar w/S3; but this is how I would start my quest.)
精彩评论