Posted by Fayna on February 22, 2009 at 8:30pm
Jump to:
| Project: | Teaser Thumbnail |
| Version: | 6.x-1.4 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
I was originally using IMCE with TinyMCE 3.x for images and Teaser Thumbnail worked wonderfully. Now that I'm trying out Image Assist with TinyMCE instead, thumbnails don't show up at all with teasers. This problem only happens when I change the image's output format to "filter." If the output format is HTML, the thumbnails show up as normal.
Also, the image will continue to show up in the node's full view with either output format.
I'd really like to use the filter output method as that seems to be the preferred option. Any ideas?
Comments
#1
Does not work for me also with image assist, not even with HTML format. It just strips out IMG. It works fine with IMCE.
#2
Same here. And I'm not using TinyMCE.
Whether ImageAssist it's set to Filter or HTML, no IMG tag is generated in the teaser view. The rest of the HTML is, though (Span, etc), giving me blank space with the caption in it. The only time I can get Teaser Thumbnail to work is when I attach the image (Image Attach or Upload module as a file) and set the Teaser Thumbnail options to allow it to use file attachments.
Would really love to place images inline in the body tag and have a module figure out how to take one of those tags, locate the associated image, and resize it according to ImageCache presets in order to display it as a thumbnail, or (shoot for the stars, right) parse it into a node variable that I can control in the tpl file and take out the corresponding IMG tag from the body on the fly....
:D
Very impressed, all around, with the functionality that has been provided with respect to images - tough code, and lots of it works.
#3
Here is a solution for ImageBrowser: http://drupal.org/node/437576
Simply set URLs that will be served through Apache - and it WILL WORK! (for new images)
#4
Img_assist or rather imag_node?
I guess teaser thumbnail does not take image from image_node to create a thumbnail...
So now in my teaser build with image_node I can only see image caption and title which I'd like not to see, but to show only small picture...
Anyone know how to write some patch on this?? To show thumbnail image and hide caption and title of image in teaser?
#5
Not sure this helps you Konrad, but here goes:
With ImageField and ImageCache, you can get some major control over captions etc.
Just create a preset in ImageCache called "teaser_image"
On your content type, create an image field for it.
Then in the content type display settings, under "teaser," make sure you select the "teaser_image" preset for your image field, and set the label to "hidden"
Also in the content type, make sure your image field comes before the body tag.
Or you can get a bit more fine-grained control by working with the tpl files.
I used some PHP in node.tpl.php to conditionally display different layouts if it was in teaser mode or not. In teaser mode, I explicitly called my image field before I called the body content (only the body - not the $content variable). I put float on it in my CSS, and it all worked out. Keep in mind that it will behave according to the preset you gave it under the display settings for the content type.
<?php
//start tpl?>
<?php if($teaser): //if in teaser mode ?>
<h3 class="title">My title</h3>
<div class="content">
<?php print $node->field_myimagefield[0]['view']; //this prints the first image in the field (if you've allowed for multiple images)?>
<?php print $node->content['body']['#value'];?>
</div>
<?php else: //if a Full Page Node?>
<!-- do full page node html here -->
<?php endif;?>
If you want even more control, you can look for the theme functions in the Imagefield module code, copy them to your template.php file and work with them to add classes or affect the HTML as you need (I'm not completely familiar with them, so take that with a grain of salt ;).
#6
Hi!
Thanks for answear.
I found I may have what I want just using CCK and node-reference!
Just found how great options it has!
Some small changes in node.tpl will be needed too but I hope I'll manage to receive what I need.
#7
This module can be made to work with image assist by adding the following code at the begining the _teaserthumbnail_get_local_images function in teaserthumbnail.module.
// If the image assist module is installed, run its filter firstif (module_exists('img_assist')) {
$text = module_invoke('img_assist', 'filter', 'process', 0, -1, $text);
}
This basically provides the search with the real HTML without the image assist macros.
I'm not sure if this is the most efficient way to do this, but it works for me.
#8
Even when using Image Assist I can't reproduce the bug: could you have a look at it with the latest versions of Teaser Thumbnail and Image Assist and let me know if there is still a problem? in theory, when Teaser Thumbnail is looking at the content of the node, Image Assist's filter converting the [img] markup into an actual
markup should already had been processed. If there is still a problem, trying playing with the modules weights (in the system table, just add a very heavy weight to Teaser Thumbnail).
#9
Hi hunvreus,
Sorry for taking so long to get back to you on this.
I've just run through the code in a debugger. The Image Assist filter is invoked during the node load process. The call to _teaserthumbnail_get_local_images however, is made during the node save process. I am therefore pretty sure any images inserted into a post by IA will be in macro form when _teaserthumbnail_get_local_images comes to operate on the data.
Thinking about it, this makes sense. During a save IA wants the image information in the compact macro form for storing in the database. During a load it expands the macro (using its implementation of hook_filter) to format the image according to the current settings.
During a save, _teaserthumbnail_get_local_images has to work with something like:
[img_assist|nid=42|title=|desc=|link=node|align=right|width=250|height=188]
which doesn't get picked up by the regular expression and results in no thumbnail being generated.
As mentioned by Fayna in the initial post, changing IA's insert mode to "HTML Code" instead of "Filter Tag" is a possible workaround, but this is not the preferred way of using Image Assist.
Hope this helps.
#10
There should be a switch for whether use filter.
Otherwise It will make no-necessary thumbnails generated by modules like smileys.
#11
I've used this to successfully force thumbnails on teasers with images embedded with Image Assist. It will convert all teasers that contain IA's filter tag(s). Maybe it can provide clues to possible future integration? It would be nice to have an all-in-one solution.
** EDIT: Code deleted. Use this version: http://drupal.org/node/380356#comment-5248710
#12
** Another code snippet update. See http://drupal.org/node/380356#comment-5248710, below.
#13
Using check_markup() instead of singling out img_assist_filter().
/**
* Implementation of hook_nodeapi().
*/
function iathumbnails_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
switch ($op) {
case 'load':
if ($node->teaser) {
// Change img_assist macro so that it loads a thumbnail.
$text = $node->teaser;
$processed = FALSE;
foreach (img_assist_get_macros($text) as $unexpanded_macro => $macro) {
$nid = $macro['nid'];
$image = node_load($nid);
if (isset($image->images['thumbnail'])) {
$thumbnail_info = image_get_info($image->images['thumbnail']);
// Clearing caption here.
$thumbnail_info['title'] = '';
$thumbnail_info['desc'] = '';
// Align all images to the left.
$thumbnail_info['align'] = 'left';
$adjusted_macro = $unexpanded_macro;
foreach (array_keys($thumbnail_info) as $attr) {
$adjusted_macro = str_replace($attr . '=' . $macro[$attr], $attr . '=' . $thumbnail_info[$attr], $adjusted_macro);
}
$text = str_replace($unexpanded_macro, $adjusted_macro, $text);
$processed = TRUE;
}
}
if ($processed) {
// We need to run filters again in order to avoid disappearing
// images due to content caching. Also - we're storing filtered
// teaser into temporary variable, otherwise the result could be
// saved to the db on node_save(). We'll retrieve it using
// template_preprocess_node().
$node->teaser_filtered = check_markup($text, $node->format, FALSE);
}
}
break;
case 'rss item':
// This will run the filter on RSS teaser output.
if (isset($node->teaser_filtered)) {
$node->teaser = $node->teaser_filtered;
}
}
}
function iathumbnails_preprocess_node(&$vars) {
if (isset($vars['node']->teaser_filtered) && !$vars['page']) {
$vars['content'] = $vars['node']->teaser_filtered;
}
}