- Drupal Multimedia
- Aaron Winborn
- 695字
- 2021-05-28 17:41:50
Teaser Thumbnails
Our next project requires us to use teaser thumbnails for articles. We have been hired by The Seedy Grapevine, a local social gossip column, to create an online version of its weekly rag. One of its requirements is to add an optional teaser image to its articles, which will display as a thumbnail on the front page and a larger image on the article page.
As is usually the case, there are many possible solutions to this need. But because it's not paying us much, and we want to just get the job done quickly, we're going to do the easiest thing we can. Yet its editors will be happy because the quick route is also easy for them to use. It's out of the box, and though there are certainly more complex solutions (often required for complex needs), our solution will harness the power of the Image module that we've already seen.
Image attach
The Image attach module is included in the Image download. Since we've already installed and configured that module, we just need to visit Administer | Site building | Modules (at /admin/build/modules
) and activate the Image attach module.
This will allow us to attach image nodes to any other type of content. For the purpose of this project, we will use the Story type content, which is built-in and active by default on all Drupal sites. For a more complex solution, we would probably build our own type with multiple image fields (which we'll do in the next chapter). But we would still be able to use this module with those types, if it were the best solution.
To attach images to a content type, we must visit the settings page for that type. In this case, we'll go to Administer | Content management | Content types | Story (at /admin/content/node-type/story
):

Now we just change the settings we need. Obviously, we'll first enable Attach Images. Leaving the Teaser image size at Thumbnail, we'll change the Full node image size to Preview.
The weights (from lowest to highest) determine where in the content the image will be displayed in relation to the body and fields (if using CCK fields) of the node type.
Attaching Images to Content
Now we are ready for our editors to actually begin attaching the images. As with images, you may wish users with an editor role to be able to create stories on the site by assigning that permission at Administer | User management | Permissions (at /admin/user/permissions
). Users in this example must have both the permission to create story content and to create image content.
Putting on our editor hat, we go to Create content | Create Story (at /node/add/story
). We'll add a juicy title, the body content of our article, and then open the fieldset that reads Attached images:

We can go ahead and insert an existing image that's been uploaded to the site from the Existing Image drop-down selector, or we can upload a new image directly from this form. In our example, we'll upload our new image here, hit Save, and see the new image magically float into our content!

Navigating back to our home page, we'll see the new image as a teaser thumbnail for our new story as well:

Note that you may not want editors to be able to attach existing images to content. For instance, if you have a site with multiple uses of image nodes, such as with a gallery, it may get too confusing to keep them sorted. On the other hand, note also that image nodes created with Image attach will automatically be marked as not published and so they will not show up for users except as an attached image.
To disable the option to attach existing images, navigate to Administer | Site configuration | Images | Image attach (at/admin/settings/image/image_attach
).
You may wish to change the placement of the attached image. For the most part, you'll need to change your theme's stylesheet to do this. The Image attach module automatically floats attached images to the right using its image_attach.css
file. We'll learn more about overriding stylesheets in later chapters.
- Excel商務數據分析與應用(慕課版)
- UI 設計入門一本就夠
- SolidWorks 2008機械設計一冊通
- Excel 2010 商務數據分析與處理(第2版)
- 好的PPT會說話:如何打造完美幻燈片
- ASP.NET MVC 1.0 Quickly
- COSPLAY的后期藝術:Lightroom+Photoshop修圖技法攻略
- 正則表達式必知必會(修訂版)
- Asterisk 1.4 : The Professional's Guide
- IBM WebSphere eXtreme Scale 6
- JBoss Tools 3 Developers Guide
- 中文版Illustrator 2020基礎教程
- Photoshop CC設計與應用任務教程
- Creo 4.0中文版基礎教程
- AutoCAD 2020中文版從入門到精通(升級版)