News Manager: Post images / thumbnails

(since 2.5)

You can have images/thumbnails in your posts, that will be inserted between the post date and content/excerpt.

Setup - Backend:

Insert this line in your site root gsconfig.php file:

$NMIMAGEINPUT = true;

A new field "Image" (in English) will be available in the post options, where you can insert the image URL/name, full or relative to data/uploads/  or click the file browser button, which opens a new window where you can select a (previously uploaded) image.

Examples:
myimage.jpg or http://example.com/data/uploads/myimage.jpg
images/myimage.png or http://example.com/data/uploads/images/myimage.png

Instead, you can also set  the position of the Image input box in the post edit page by using one of these:

$NMIMAGEINPUT = 0; // or FALSE : not visible

$NMIMAGEINPUT = 1; // in Options, first field

$NMIMAGEINPUT = 2; // or TRUE : in Options, last field

$NMIMAGEINPUT = 3; // directly visible above content

$NMIMAGEINPUT = 4; // directly visible below content

By default, the file browser lets you select images in the data/uploads folder. If you want to select from a certain subfolder, you can use this gsconfig setting:

$NMIMAGEDIR = 'images';

(default subdirectory for image selection, relative to data/uploads - e.g. 'images'  for data/uploads/images/)

Frontend settings:

These tags can be inserted in your nm-init component (edit or create it), or if you want custom settings depending on the news page type, in nm-top-single (for full post page), nm-top-archive (for archives), etc. See some examples.

Show post images (default):
nm_enable_images();

Do not show post images:
nm_disable_images();

Define image size:
nm_set_image_size(width,height);

Same but with cropped images (scaled to have at most width / height dimensions; if third parameter is 1 or true, it is cropped to exacly fit the width / height ratio):
nm_set_image_size(width,height,true);

Insert alt="post title" attribute in <img> tags:
nm_set_image_option('alt');

Insert title="post title" attribute in <img> tags:
nm_set_image_option('title');

Make images link to posts:
nm_set_image_option('link');

Allow external images (they will not be resized/cached):
nm_set_image_option('external');

Default image for posts that have no image set (if not defined, no image is shown):
nm_set_image_option('default','image.jpg');

Resized images are cached (stored in data/thumbnails/) by mvlcek's pic.php script.

Styling / CSS

You can style images with new class nm_post_image, example:

nm_post_image {

  float:left;

  border:1px solid #ccc;

  margin-right:20px;

  padding:0!important;

}

.nm_post_title { clear:both }

(See another example by D.O.)