I don't think that somebody uses inline image with no alignment. The normal case is:
align="left" oder align="right". This is what we need in 95% of all cases or more.

So it would be great to have a default alignment or to have a selectbox or button to choose alignment or to choose left or right alignment.

Is it possible to realise this with template file tpl.php? Or would we need a patch for this?
Thanx.

Comments

Breakerandi’s picture

subscribe

varkenshand’s picture

I always use class:left, class:right or class:center. This enables me to set additional padding commands in CSS. Insert allows a default class attribute to be entered. Provides a good workaround.

drupalfan2’s picture

Where is it possible to choose a default class attribute in insert?

quicksketch’s picture

I don't plan on adding this functionality. Usually you'd leave this to the WYSIWYG editor you're using.

drupalfan2’s picture

But unaligned images nobody needs. Do you use unaligned images where the text is floating unusable?

It is not possibe to tell the richeditor that the insert module should insert html-code like this ".... align='left' ...." or ".... float:left ...". This html tag comes from insert module, only the insert module can set this html code.

Think about this:
Insert module can also be used with normal drupal textfield (without richeditor). Exactly what insert module inserts, exactly this html code will be placed there. The only way to solve this is to tell the insert modul to insert the correct alignment.

This is the correct way. But this feature could be disabled by default if you don't want to use ist by default.

varkenshand’s picture

Administer - Content Type - Manage Fields.
Pick the Image Field in question.
Configure Field.
Choose Insert Option.
Additional CSS Classes is right there.

drupalfan2’s picture

I don't think that this can be a solution.

Within an article the first image has to be aligned left, second image aligned right, and so on. Perhabs fourth picture has to be aligned centered.

And within the next article 3 images have to be aligned right.

And within the next article there are 2 images aligned left and one aligned right.

HOW CAN THIS BE SOLVED with your last idea?

drupalfan2’s picture

See above:

So it would be great to have a default alignment or to have a selectbox or button to choose alignment or to choose left or right alignment.

Is it possible to realise this with template file tpl.php? Or would we need a patch for this?

quicksketch’s picture

It is not possibe to tell the richeditor that the insert module should insert html-code like this ".... align='left' ...." or ".... float:left ...". This html tag comes from insert module, only the insert module can set this html code.

Both FCKeditor and tinyMCE have support for the align attribute, you just have to configure them to use HTML 4 instead of XHTML, in which case they will use style="align: left;" instead of align="left". I actually suggest doing this because it allows for more flexibility while preventing users from using extensive CSS that may break your layout.

drupalfan2’s picture

Whenever I insert a image with the imsert module I have to choose which alignment this image should have. This has nothing to do with CKEditor or tinyMCE. You are speaking about a different thing.

http://drupal.org/node/713440#comment-2624396

quicksketch’s picture

Right, I'm saying that I won't be adding alignment to Insert because you can already align images with FCKeditor or tinyMCE. It's the same number of clicks either way, plus it makes it consistent if the user later wants to change alignment from left to right.

Current workflow:
- Upload image.
- Click insert.
- Click right or left align from WYSIWYG toolbar.

Proposed workflow:
- Upload image.
- Select right or left align from Insert form.
- Click insert.

There's no benefit to duplicating alignment controls when you already have them in one place.

Breakerandi’s picture

The big benifit is in the usability! My users don't know, that they can change the view of an image uploaded with insert by clicking a image button somewhere else.. Thats not logical..

quicksketch’s picture

Status: Active » Closed (won't fix)

There are a lot more options than just alignment though. After aligning left, the user may then want:

- To add a link to the image
- Add some padding around the image
- Add a border

It just doesn't make sense to duplicate all of this in two places. I won't add this feature. That's it.

drupalfan2’s picture

>>Click right or left align from WYSIWYG toolbar.

This does not work for me. Clicking on left align button in TinyMCE (after image has been marked) does nothing!

Left align button is to align text and NOT to align images.

drupalfan2’s picture

Problem solved by myself:

It is possible to achieve default alignment:
- Edit lightbox2.insert-image.tpl.php in lightbox2 module
- change <img src="<?php print $url ?> .... to <img style="float: left;" src="<?php print $url ?> ....

All with insert module inserted and lightboxed images are aligned left by default. This is what we needed. (You could have told us this before).

The same can be done with not lightboxed images.
- Edit insert-image.tpl.php in insert module (copy it to your theme)
- change <img src="<?php print $url ?>" ... to <img style="float: left;" src="<?php print $url ?>" ...

manuel.solis’s picture

Ok, It can be done!!!

If you use ImageCache, change imagecache-insert-image.tpl.php to:

// $Id: imagecache-insert-image.tpl.php,v 1.1 2009/10/21 06:23:43 quicksketch Exp $

/**
 * @file
 * Template file for ImageCache content inserted via the Insert module.
 *
 * Available variables:
 * - $item: The complete item being inserted.
 * - $url: The URL to the image.
 * - $class: A set of classes assigned to this image (if any).
 * - $preset_name: The ImageCache preset being used.
 *
 * Note that ALT and Title fields should not be filled in here, instead they
 * should use placeholders that will be updated through JavaScript when the
 * image is inserted.
 *
 * Available placeholders:
 * - __alt__: The ALT text, intended for use in the <img> tag.
 * - __title__: The Title text, intended for use in the <img> tag.
 * - __description__: A description of the image, sometimes used as a caption.
 */

Only local images are allowed. print $url " img style="margin: 10px; float: left;" alt="__alt__" title="__title__" class="imagecache- print $preset_name print $class ? ' ' . $class : '' " />

If you don't use ImageCache, change insert-image.tpl.php to:

// $Id: insert-image.tpl.php,v 1.1 2009/10/21 06:23:43 quicksketch Exp $

/**
 * @file
 * Template file for generic images inserted via the Insert module.
 *
 * Available variables:
 * - $item: The complete item being inserted.
 * - $url: The URL to the image.
 * - $class: A set of classes assigned to this image (if any).
 * - $width: The width of the image.
 * - $height: The height of the image.
 *
 * Note that ALT and Title fields should not be filled in here, instead they
 * should use placeholders that will be updated through JavaScript when the
 * image is inserted.
 *
 * Available placeholders:
 * - __alt__: The ALT text, intended for use in the <img> tag.
 * - __title__: The Title text, intended for use in the <img> tag.
 * - __description__: A description of the image, sometimes used as a caption.
 */

Only local images are allowed. print $url " width=" print $width " height=" print $height " alt="__alt__" title="__title__" print $class ? 'class="' . $class . '" ' : '' />

drupalfan2’s picture

Hello manuel.solis,

your tpl.php code only contains comments. Maybe you didn't post the whole file content here.

Melissamcewen’s picture

manuel.solis , I'd love to get your full code too.

pfx’s picture

Did you try the module "Custom formatters" it works perfectly with the module "Insert".
- I made a formatter "Image float left":
<img style="float: left;" class="imagecache-image220" src="/[filefield-imagecache-image220]">
another "image float right" and a "Image no float".
- After that select your own formatters in "Enabled insert styles:" into your ImageField.
- Now Insert is able to inject your own Format into your text area.

Melissamcewen’s picture

Thanks for the tip PFX!

adrianmak’s picture

Why I cannot see imagecache token in my site ? Should additional modules are required ?

manuel.solis’s picture

So sorry!!!
In imagecache-insert-image.tpl , replace this:

<img src="<?php print $url ?>" alt="__alt__" title="__title__" class="imagecache-<?php print $preset_name ?><?php print $class ? ' ' . $class : '' ?>" />

With this:

So sorry!!!
In imagecache-insert-image.tpl , replace this:

<img src="<?php print $url ?>" img style="margin: 10px; float: left;" alt="__alt__" title="__title__" class="imagecache-<?php print $preset_name ?><?php print $class ? ' ' . $class : '' ?>" />

Good luck!

nubeli’s picture

I can see that it's best to leave this to the wysiwyg editor, but right now the only way to align it in the editor is by using HTML instead of assigning classes - my preferred way. I like the way image(field) assist does it by providing default classes for align left, right and center (and allowing the option of a filter tag instead of having to allow the Only local images are allowed. tag). Then in the css you can have uniform padding, borders for each alignment. Problem is that it doesn't work nicely with WYSIWYG api.

Another quick way of allowing the user to assign alignment (and not just the default) is by creating a different preset for each of left, right and center. Then in the theme assign floats and padding to each. It may mean you get two or three images of the same dimensions but not too many.

bryancasler’s picture

How can I accomplish this on D7?

bryancasler’s picture

For D7

Change sites\all\modules\insert\templates\image-insert-image.tpl.php

From

<img src="<?php print $url ?>" alt="__alt__" title="__title__" class="image-<?php print $style_name ?><?php print $class ? ' ' . $class : '' ?>" />

To

<img src="<?php print $url ?>" alt="__alt__" title="__title__" class="image-<?php print $style_name ?><?php print $class ? ' ' . $class : '' ?>" style="float: right;"/>