I decided to write this after having read an awful lot of posts about the struggle to make sense of images in drupal and still finding it relatively difficult to achieve this simple requirement myself. I know I am by no means the first to post about this issue and I certainly do not claim to be any kind of expert (at the time of writing I have been looking at drupal for about a week). However, this guide might help anyone with a need to have thumbnail images on teasers and larger images on pages.
Stage 1 - drupal version and required modules
If you are still reading then you need to be using drupal 4.7.x, enable the upload core module and install and enable these contributed modules:
cck.module (contributed module - http://drupal.org/project/cck)
imagefield.module (contributed module - http://drupal.org/project/imagefield)
imagecache.module (contributed module - http://drupal.org/project/imagecache)
Stage 2 - Configure the two required imagecache "presets"
Q: What is an imagecache "preset"?
A: An action that will automatically be performed on the uploaded inages.
Q: How many presets can I use?
A: Many presets can be used but only two will be required for our needs.
Preset 1 - needed for the main image that will display on the node's page
namespace: yourcontentnode_mainimage
action: scale
width: 400
height: 400
scale to fit: inside dimensions
weight: 1
Preset 2 - needed for the thumbnail image that will display on the node's teaser
namespace: yourcontentnode_thumbnail
action: scale
width: 100
height: 100
scale to fit: inside dimensions
weight: 0
Please note that I have set the dimensions of the main image to be 400x400 pixels and the thumbnail to be 100x100 pixels. Obviously you will need to set the size of the images to suit your needs.
Also note that preset 1 is weighted "1" and preset 2 is weighted "0". This ensures that when the image is uploaded the first action is to create the main image from the original (which may be larger than 400x400 pixels) and the second is to create the thumbnail from the 400x400 pixel image (and not from the original I think).
Stage 3 - define the node content imagefield
Q: What is an imagefield?
A: It is a CCK field type that we are using to hold the uploaded image. Do not confuse this with an image node that would be created by the image.module or with a flexinode.
I am presuming that at this stage you already have the content type defined. If not create one and return here.
1. Administer your content type and create a field of type "image" (this makes it an "imagefield")
2. Give the image "label" meaningful to users e.g. "image" (we will assume "image" has been used in the rest of these instructions).
3. You do not need to set a "Maximum resolution" unless you are allowing the original image to be stored on your server (see 5.)
4. Set an "image path" if necessary to allow the original image to be stored but know that the path will also be used in the imagecache directory strucure
5. "Enable custom alternate text" if you need to.
6. "Enable custom title text" if you need to.
Imagecache Options
7. "Teaser preset" - set this to the imagecache preset (created in Stage 2) that defines your thumbnails e.g. yourcontentnode_thumbnail
8. "Body preset" - set to the imagecache preset (created in Stage 2) that defines your main image to be displayed in the node page body e.g. yourcontentnode_mainimage
Data settings
9. "Required" - set if you require that every content entry of this type must have an image
10. "Multiple values" - tick if you will allow users to upload and display more than one image for each content entry. Note that both the multiple thumbnails and main images will be displayed.
11. Save the settings.
Stage 4 - edit the node content image field to upload an image
Find the "image" section (remember this name was given in Stage 3 above)
1. click "browse" and select the image file to be uploaded.
2. click "upload" to upload the file which will then be automatically imagecached to two new files with "mainimage" and "thumbnail" settings.
3. click "submit" to save your changes to the content node.
Stage 5 - verify the result by viewing the content node
1. Navigate to the page view of your content node to check that the "mainimage" format of your image is displayed.
2. Navigate to a teaser view to check that the "thumbnail" format of your image is displayed.
Stage 6 - review the imagecache files that were created
if we assume that you did not set an [image path] in section 3) above then you should see the following directories on your web server
yoursitedirectory/files/imagecache/yourcontentnode_image/files
yoursitedirectory/files/imagecache/yourcontentnode_thumbnail/files
the first contains the imagecache preset "mainimage" files e.g. the 400x400 pixel images
the second contains the imagecache preset "thumbnail" files e.g. the 100x100 pixel images
End of guide
P.S. Please note that this is my first attempt at creating a useful guide and excuse me if I have made some errors, used an inappropriate format or posted in the wrong part of the forum :)
Comments
How to get the Original to Stop Displaying
I don't really know if this a problem that others were experiencing of if it is desired behavior. After installing imagefield.module and imagecache.module I wanted my image field images to stop showing inside my nodes because i was going to use image cache to make them all a uniformed size for some added continuity to my site. But if you have tried to do this you will notice that the image from image field was loaded into content. So one way to accomplish this is to modify your template pages, but why should we do this if we this change for everypage. Instead I recommend overriding
theme_imagefield_image()in imagefield.module. This way you could use your default profile you created in imagecache and already have you image included and resized the way you wanted with very little work on every page. And you can also add a rather wide variety of advanced functions using this method as well with very little work.That sounds confusing now that I read that back to my self and stock full of typographical errors, but I'm on a crunch. If that doesn't make sense leave a message and I will correct.
Peace,
-mpare
www.paretech.com
Did you figure out how to do something? Did you find documentation on Drupal.org inadequate? Well now it's your turn. Document your Success!
Should have follow up sooner!
I don't really know what I was thinking when i originally made this request. A short while later I found the answer I was looking for. Behold
theme_imagefield_image! Using this function I was able to have my images attached to a node with imagefield display all in a uniform size. Below is my code, though possibly not the best. These work and I have even included some code so that thickbox is encluded. Also my code uses two different presets to determine a horizontal or verticle layout and uses the correct imagecache preset. just change the two lines that read $preset = ''; in the if statement to set to your sites imagecache presets. Hope this is of benefit to someone. BTW, I never completed the info being passed during the link generation and I also probably should have used t() and l() when creating my links. That shouldn't take but just a second to fix. Without and more waiting here is the code...Peace,
-mpare
www.paretech.com
Did you figure out how to do something? Did you find documentation on Drupal.org inadequate? Well now it's your turn. Document your Success!
Revival of "Teaser Image" module
IMHO all those approaches are far to complex to get somethig, which should just simply "happen"... large pictures in teasers should never appear, regardless of other circumstances and without hassle.
For me, a recode of the very very old "Teaser Image" does that job:
a) in your modules folder, create a folder called teaser_images
b) in teaser_images create a file teaser_images.info with the following content
; $Id: Exp $
name = "Teaser Images"
description = "Downscale Teaser Images"
version = "5.x-2.0-dev"
project = "teaser_images"
c) in teaser_images create a file teaser_images.module with the following content
d) turn it on at admin/build/modules
e) there is NO config. if you want other resolution, change it in source (100,100)
any feedback on this is welcome!
thx
Combined approaches
I decided to combine the two approaches, and use this replacer method with the imagecache module.
I just added the functions to an existing module (scwc.module) containing customizations for the site I'm working on. Previous to this I created an imagecache preset called 'teaser'.
Simple!
is it possible by this
is it possible by this method to disable link of teaser images? i use img_assist on my site, which actually can put images without links, but it is impossible to control so that users would place linked image to node bodies and separately images without links to teasers. so i am searching for some kind of method to disable links for images in teasers.
yes it works
I did this in heimstein's teaser image module above by simply removing the a tag in this code:
so now it looks like this:
deleting duplicate message
deleting duplicate message
I tried for about an hour
I tried and tried...
I am new so I am sure I screwed up... but can't figure out were...
The images just go away...
(No subject)
(No subject)
is it possible by this
is it possible by this method to disable link of teaser images? i use img_assist on my site, which actually can put images without links, but it is impossible to control so that users would place linked image to node bodies and separately images without links to teasers. so i am searching for some kind of method to disable links for images in teasers.
Problem with imagecache
When I am trying to make a folder inside my files in Drupal and trying to place an image inside that folder and after that I tried to update it , the folder inside the files vanishes. Also, the imagecache folder is not visible in my files folder, even if I enable the module.
My path is as follows...
http://example.com/files/imagecache/test_25/
I will summarize again...Cant see the folder imagecache inside files...moreover when I created this folder and after creating the preset named as test_25, when I try to update it the entire folder vanishes..Please help me ..
Yes
Yes
Well, with 5.x anyway.
You have an option to select Hidden instead of a link or preset, as described here, for teaser.
Quentin Campbell
teaser image works great
Thank you heimstein, the little module works great, I'm using it for my products listings.
I was able to disable the link to the regular image in the code but what my customer wants is for it to link to the regular size image plus a description of the product. I use !--break-- so the description doesn't show up in the teaser. Is it possible to get the thumbnail to link to the full node rather than the regular size image?
Float image in teaser images
Thank you heimstein, it works great...
The only problem is that the teaser images are not anymore
floating left of the text like it is in the original node.
How can i float the teaser images left of the text?
10 PRINT "HELLO WORLD!"
20 GOTO 10
Revival of "Teaser Image" module is incompatible with Drupal 6.1
Hello there,
I have tried implementing the example called "Revival of "Teaser Image" module by heimstein - March 4, 2007 - 19:36", but when I went to turn it on via the admin/build/modules I got the following error message:
“Teaser Images / 5.x-2.0-dev / Downscale Teaser Images
This version is incompatible with the 6.1 version of Drupal core.”
I am a newbie to Drupal and have been looking for a good few days now in order to find a way to display / view the uploaded images.
- When logged in as the admin I can see the attachment & size of the uploaded file/image
- When I logout then I can’t see no trace of this image at all
- The uploaded files do however get uploaded into the sites\default\files folder
At this point I feel that it has turned out to be very difficult to do something that one would think would be pretty simple.
Any help would be greatly appreciated, because if I can’t display images then I will simply not be able to use drupal.
I would like to thank you for your time in advance.
knit-picking I guess, but to
knit-picking I guess, but to be compliant - how do I grab the ALT tag from the original and place it in $image_tag - what variable... Thanks...
yeehaw
This little module has solved my problem absolutely perfectly. Thanks so much for putting it together and offering it up.
Drupal 5.x
Thanks for this.
I'm still on a learning curve and this gave me a some training.
Everything works fine with Drupal 5.x except Stage 3, steps 1, 7 and 8:
Step 1 you click on "add field" to start creating a new field.
Skip steps 7 and 8 and finish Stage 3 (save the settings).
Select "Display fields" and here you can set teaser and full display to your presets. You can also show or hide the field label in the node.
I also need this as I want to load pictures into nodes (like blogs) without having to use albums to upload (like with image assist and Acidfree).
I got one question: How do I insert (anchor) images into specific positions in my, say, blog? I want to be able to justify it, and also put it in between text.
Quentin Campbell
How do I get the thumbnail
How do I get the thumbnail to link to the actual node instead of the larger image?
Thanks in advance.
Jon
imagecahe folder not being created
For some reason imagecache isn't creating a folder within the files folder nor is it creating different versions of the uploaded image. Needless to say I have broken image links. I'm using drupal version 5.3 and imagecache 5.1.3. Any ideas what is going on? Also it may be helpful to note I haven't switched to clean URL's yet either.
I had it working on Drupal
I had it working on Drupal 5.1
Upgraded to Drupal 5.3. Got the latest version of Imagecache. And now its broke. It is not creating either the folder or the thumbnail.
Disabled imagecache and
Disabled imagecache and re-enabled. That made it work.
However now i figure that imagecache does not create thumbnails for some file types.
image.module can do this too
image.module can do this too -- if not the latest version, then in one coming soon as I've seen the code in CVS HEAD :)
theming the image field(s)
Hello all, this is a very good howto but i want to know how i can style the image field in the teasers...
i want to have the image next to the text..
image text text text text
text text text texttextext
text text text text
how can i do that?...
With image_attach: use CSS
With image_attach: use CSS to float the image left instead of right.
With imagefield module: change the node template in your theme.
Thank You So Much!!
Thank You So Much!!
thanks for the tip
but can you give me an example of how to do this in the imagefield module case...
Just change the theme to overide the image attach settings
You can accomplish the same thing just using the image attach module them.
In your theme folder (sites/all/theme/yourThemeName, in the template.php append this code:
and you are finished ....
the above solution fails if you can't have imagenode because your site doesn't allow url names...
Subscribing. Greetings, Marti
Subscribing.
Greetings,
Martijn
Question
I didn't catch how to do that:
>Imagecache Options
>
>7. "Teaser preset" - set this to the imagecache preset (created in Stage 2) that defines your thumbnails e.g. yourcontentnode_thumbnail
>8. "Body preset" - set to the imagecache preset (created in Stage 2) that defines your main image to be displayed in the node page body e.g. yourcontentnode_mainimage
So uploaded images have original size, and I would like to have them resized (and with thumbnails). May be I've done something wrong? HELP!
So, can anybody help me? How
So, can anybody help me? How to configure these modules to make them function correct?
I'm in the same boat
peaceful, I have tried and tried...
I can't get it to work.
The teaser always shows the original image
the full node always shows the original image
I could also use some help. please.
I didn't realize it at first
I didn't realize it at first but these ImageCache options are defined within CCK's "Display Fields" tab now. You go to the content type with the image field you want to edit, then click on the "Display Fields" tab. There you can change the display of the image field (and other fields too) based on teaser or full (body view) as well as the label. Your ImageCache presets should show up in the drop-down for each of these.
When following this guide I got lost on that part too. It needs to be updated. :P
this should be done once u
this should be done once u have saved the field....go to admin/content/types//display
I followed all the steps
I followed all the steps above by "scarything". I now can see a thumbnail in the teaser and the original size image in the full node. What I will like to do is to have the thumbnail in the full node and when you click on it, it should show the original size image. Something similar to what lightbox does http://www.huddletogether.com/projects/lightbox2/
Any ideas?
Found the solution using the
Found the solution using the LightBox V2 module. Thanks
I have multiple images for
I have multiple images for my nodes? Does anyone have a solution in which I can draw only 1 image? Currently with Views, ImageField/ImageCache, I am able to specify which thumbnail I want to be displayed on a view, but find it limited because if I have more than one image attached, all the images will use the preset, and hence, I would have them all thumbnailed rather than just 1 being displayed.
pictures retain their original size
I have tested many times I do not find the error
THE DISPLAY AND THE THUMBNAILS pictures retain their original size, someone he managed to solve the problem?
http://blip.tv/file/256997
CCK Content Construction Kit (CCK)
http://drupal.org/project/cck
VIEWS
http://drupal.org/project/views
VIEWS BONUS PACK
http://drupal.org/project/views_bonus
CUSTOM PAGES
http://drupal.org/project/custom_pagers
IMAGEFIELD
http://drupal.org/project/imagefield
THICKBOX
http://drupal.org/project/thickbox
IMAGECACHE
http://drupal.org/project/imagecache
DRUPAL 5.7
i can't use "Clean URLs" because i m not admin of the Apache serveur (1and1.com)
other plugins :
TinyMCE, WEBFORM, CAPTCHA, SWF TOOLS, Google MAP
removing title from image...? Please help...
Hi, I followed instructions above and they work a treat except for one thing...
Both the thumbnail image and the post image both have a title above them...
I would like to have no title at all with the image, just the image on it's own as the title is not really needed.
When creating the imagefield, the title attribute is mandatory... I tried putting in which works to some extent, but i am still left with a colon (:) where the title would be.
Us there a way that i can get this title removed completely?
http://www.youthparticipation.ie/testnewsitem
The page listed shows an example, where the colon is left above the image...
Using:
Drupal 5.6
UPDATE: I am a fool - this setting is located in content type / display fields... set label to hidden
Creating multipage Galleries?!!
Any ideas on how to make the images in a gallery added via imagefield spread across multiple pages?!!
Can't seem to find the configuration option for the same!!
Attached images don't show up
I went through the whole process as outlined above and when I try to upload an image to put with my node, it never works. I get a blank image with the red X, and if I try to save it, it will say an image is required (since I set it up that way for this particular node type).
Need a simple help on
Need a simple help on imagefield images in teasers and full nodes to simply appear left floating and 2px padding from text,thats'all.
I will do fixed size for teasers and full nodes, so no imagecache settings or strange things. Just a a little help on how to ovverride theme to accomplish this left floating and "2px distance from text" formatting.
thanks
imagefield image display in page
Same here, I have my content type set up for multiple images using imagefield and if more than one image is uploaded the content drops down to the second image so my display looks strange. I'm not using imagecache either for this, just default display. I don't understand why the text doesn't wrap around the first image since both are set to align left. ??
Just Subscibing
Subscribed
I'm using imagecache wich
I'm using imagecache wich add a few classes to the images.
You need to find the class of your image or a surrounding div and put something like this in a css file
Could you be more specific
Could you be more specific about class image.I'm newbie in Drupal and I need this solution for imagefield.Where is the css file about you talking.Could you write example for class name of images?
Theming a teaser image, made with cck imagefield and imagecache
If you want to display a teaser image, witch made with cck-imagefield and resized with imagecache:
Change in the node.tpl.php this:
to this one:
Add to the style.css:
I have multiple images for my
I am facing the problem. The default Drupal upload module gives you the option to choose which one to use in the teaser. I couldn't find the same option in image cache.
This is how I
This is how I do!
http://hanief.blogspot.com/2010/02/drupal-image-cck-field-imagecache.html