Jump to content

Module: Fieldtype Image Extra (multi-language)


justb3a
 Share

Recommended Posts


This module is obsolete and will not be developed any further. 

Please use the ImageExtra Module instead.


Overview

This module allows you to add additional informations to an image (for example: title, description, link, orientation and any field you may need). If you want to, you can install FieldtypeImageExtraLanguage to get multi-language support.

For more informations have a look at the readme.

Installation
 
1a. Clone the module and place FieldtypeImageExtra in your site/modules/ directory. [OR]
1b. Download and unzip it from the module page
git clone https://github.com/justonestep/processwire-fieldtypeimageextra.git your/path/site/modules/FieldtypeImageExtra
 
2. Login to ProcessWire admin and click Modules. 
3. Click "Check for new modules".
4. Click "install" next to the new FieldtypeImageExtra module. 
  If you need multi-language support, you have to install the FieldtypeImageExtraLanguage module.
5. That's all - no settings are required but possible. 
 
Define your custom fields
 
1. Login to ProcessWire admin and click Modules.
2. Open `Images Extra Inputfield` Settings.
 
The following fields are available by default:
  • orientation - image orientation
  • orientation values - values to use as classnames or identifiers for different image orientations
  • title - image title to use for title/alt tag or/and caption, if empty, the content will be generated from the applications filename
  • description - image description
  • link - image link to internal pages
 
If these fields are not enough for you, you can add any other field (for example _author_ and _location_)
by writing it (separated by comma) in the field otherField.
 
If you don't need all custom fields, you can easily disable them.
 
One more exception is orientationValues.
Here you can insert identifiers for classnames or similar separated by comma.
This values will be available in a dropdown list.
 
Usage
 
1. Under Setup and Fields create a new field using type `ImageExtra` or `ImageExtraLanguage`.
2. After entering the new field name and label, click Save.
3. Configure it depending on your own needs.
4. Save.
5. Add your new field to one or more Templates.
 
Accessing the value
 
This is no different than accessing the value of any other field.
 
$image = $page->image->getRandom();
echo $image->title;
echo $pages->get($image->link)->url
 
For use with TemplateTwigReplace
{% set image = page.images.getRandom() %}
{{image.title}}
{{pages.get(image.link).url}}
 
Screenshots
 
ImageExtraLanguage-default-backend.png
ImageExtra-frontend.png
 
 
Here is a litte example how to access the new fields:
 
// if there are images, lets choose one to output in the sidebar
if (count($page->images)) {
  // if the page has images on it, grab one of them randomly...
  $image = $page->images->getRandom();
  // resize it to 400 pixels wide
  $image = $image->width(400);
  // output the image at the top of the sidebar
  $sidebar = "<img src='$image->url' alt='$image->description' />" .
    "<h3>$image->title</h3>" .
    "<blockquote>$image->description</blockquote>" .
    "<p>$image->author ($image->location)</p>" .
    $page->sidebar;
}
  • Like 18
Link to comment
Share on other sites

  • 5 weeks later...

This module looks great, however, I am having a bit of trouble getting it to display the image I upload. I set everything up, upload an image, and the progress bar stops at 100% without going further and showing the image as usual. When I refresh the page in the admin, there is no image associated with the image field. I checked the assets folder, and the image is getting uploaded to the proper folder, but it's not showing up on the page. I am using PW version 5.2.3.

Link to comment
Share on other sites

@thistimj: I just added some fields to store additional informations. Have you already looked into the log files? Please paste the message if there is one. Did you try to use the "normal" image field, does this work as expected? Maybe it's an ImageMagick issue but I'm not sure if it depends on that...

Link to comment
Share on other sites

The regular image field works as expected, which is why I am a bit confused as to why Image Extra wouldn't work. What log files are you referring to?
Here is a screenshot of what I'm getting. The field above is a normal image field; you can see part of the image.

screenshot.jpg

Link to comment
Share on other sites

Please...


  • watch the request (using proxy / charles, fiddler or network console)
  • check sites/assets/logs/errors.txt
  • check your server log files
  • check output in Console (Browser)

I can't reproduce this error. Any error message would be very helpful  ;)

Link to comment
Share on other sites

  • 1 month later...

Hi,

I have a strange issue.

I use the ImageExtraLanguage Field in different templates on different pages.

In the admin the images can be dragged to sort.

But on one page the new order is saved correctly, but on another page not. After saving that page, the images are reloaded in the original order.

I have no idea what causes this behavior.

Only thing is that on the page where the order is not saved, there are more then 100 images, on the other pages where the new order is saved correctly the number of images is max 15. But I can't imagine that this is realy the cause.

Thanks.

Edited by kongondo
Reems, I'm moving this to the correct forum...
Link to comment
Share on other sites

  • 2 weeks later...

Just trying this out without any language stuff.

As soon as I add anything to otherField I get:

 SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_imageextra.location' in 'field list'

What am I doing wrong? This is with the latest dev.

Link to comment
Share on other sites

@reems Did interrobangs solution solve your problem?

@Joss Try to reassign the Fieldtype ImageExtra. I assumed that you first enter your module config and then add the Fieldtype.

The other sequence does not work atm (I have this as a bug on my whiteboard  ;) ). The new database columns will be inserted only by FieldType switching. 

Link to comment
Share on other sites

Okay, half worked.

I had just one custom field of "location" - switched and that was fine.

I then created changed the config adding a couple more customs "location, type, date"

Created a new field and then switched type. Confirming the switch it said:

SQLSTATE[42000]: Syntax error or access violation: 1072 Key column 'type' doesn't exist in table

Link to comment
Share on other sites

  • 2 weeks later...

Thanks for this - looks like it has great potential, but at the moment, you have these errors:

Warning: stripos() expects parameter 1 to be string, array given in /site/modules/FieldtypeImageExtra/FieldtypeImageExtra.module on line 229|230|231

which break the image upload due to outputting header content before the image during the ajax upload with PW debug set to true.

There are also some layout issues if you disable the orientationField - the Link field only takes up half the page width.

I had the same issues as Joss, but switching the field type did the trick!

Link to comment
Share on other sites

  • 3 weeks later...

I developed a new module ImageExtra which allows you to combine custom fields and image cropping (for example).


Please have a look at this forum post.


This module will not be developed any further. Be careful: if you decide to use ImageExtra with an existing site you'll have to start from scratch. So please make sure to backup your data - just in case you need to go back -, because the old settings are not compatible with the new module's format.


  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...