Jump to content

Module: Image Extra


justb3a

Recommended Posts

Some time ago I developed a module (FieldtypeImageExtra) which extends Fieldtype Image with the ability to add custom fields to an image. This worked well but it had a somehow restricted applicability and did not meet all of our needs. There of course are other useful image modules like CroppableImage or ImageFocusArea, but up to now there was no possibility to combine image cropping with custom fields support. So you had to decide whether to add image cropping or the possibility to add custom fields because each of those modules sets up their own field type (and input type) which cannot be combined.


 


The new module ImageExtra allows you to have both functionalities.


 


You can get the module from GitHubFor more informations have a look at this blog post.


 


If you notice any problems or unexpected behaviour please let me know.


  • Like 22
Link to comment
Share on other sites

oh, I didn't notice that topic, I would have responded as well. 

Maybe it's a good idea to add an external url field. What do you think?

If it will be able to handle a URL field well, then maybe there is no need. On the other hand, since you already a internal links feature, maybe good to add an external one too...Anyway, its a 50/50 thing...so your call :-)

Link to comment
Share on other sites

Thanks for this module, justb3a, it comes right just in time for me :-)

However, I think there is a problem: I noticed that values for "caption", orientation or custom fields are saved in database (that part works). But if I edit the same image again, the values have disappeared. The fields are empty. If the image is saved again, the values in the database get lost.

UPDATE: I tried to debug it. If I change line 1045:

$value = $this->wire('sanitizer')->entities($pagefile->{$current}($language));

to

$value = $this->wire('sanitizer')->entities($pagefile->{$current});

the problem disappears. I guess this fix does not work if you have more than one language defined.

Link to comment
Share on other sites

@titanium: First of all thanks for testing and feedback  :)

I cannot reproduce this behavior. Could you please provide me more informations:

  • ProcessWire Version
  • Number of max allowed files
  • Overwrite existing files?
  • Do you just change meta informations or upload a new image?
  • Do you use ImageExtra in combination with any other Image Module? (Please tell me which one)

I installed a fresh ProcessWire installation, Beginner Package (just one language), and it works without any problems.

EDIT: I still cannot reproduce this behavior but I changed this line to:

$value = $this->wire('sanitizer')->entities($language ? $pagefile->{$current}($language) : $pagefile->{$current});

I hope it works now.

Link to comment
Share on other sites

  • 2 weeks later...

On one of my PW sites it works fine, but on another one, if I try to edit a page with an image, I get this error:

Error: Using $this when not in object context (line 213 of /home/path/site/modules/ImageExtra/ImageExtra.module) 

Both site are using the same versions of Image Extra and PW (both the very latest).

Link to comment
Share on other sites

In line :213 the method for the image link is added. The other methods seems to work because the method for the link is called as the last one.

Did you check the  Add internal link field box? Uploading an image wasn't a problem? Did you add an image link? Does this error occurs on every page which contain this field?

Link to comment
Share on other sites

Yep, I checked add internal link field box. The image uploads fine, and i can add a link, but it doesn't matter whether I actually add the link or not, I still get that error and the only way to get it to go away is to remove the field from the template, or uncheck internal link field box for the field. It seems to occur with every page containing the field.

The only thing I can think of that might be making it work on one server vs the other is php version: 5.6.4 works, but 5.4.33 5.3.29 doesn't.

Link to comment
Share on other sites

That sounds reasonable and could explain other issues I couldn't reproduce. I've tested only with PHP version 5.5.18.  I try to take some time next week to install version 5.3.8 (ProcessWire requires at least this version) and test all again. jeah...  :mellow:

  • Like 1
Link to comment
Share on other sites

Sorry for the confusion - I was looking at the wrong server. The server in question is running 5.3.29 so it's simply an issue with using $this in the anonymous functions (not allowed in 5.3) you are using, so should be an easy fix.

  • Like 1
Link to comment
Share on other sites

Feel free to provide a solution here oder create a pull request.  ^_^

Otherwise I will look at this next week...

PR has been submitted to fix those fatal errors in PHP 5.3.

The other relatively minor (but niggly) thing is that the description field is not getting the InputfieldMaxWidth class applied to it and as a result, the input is very narrow. I took a quick look at the regex stuff you have going on in regard to this, but figured it was easier for you to figure out the issue with this because I haven't really figured out why you are replacing the label class and label for description, although I am sure there is good reason :)

  • Like 2
Link to comment
Share on other sites

Thanks for the pull request. 

The other relatively minor (but niggly) thing is that the description field is not getting the InputfieldMaxWidth class applied to it and as a result, the input is very narrow. I took a quick look at the regex stuff you have going on in regard to this, but figured it was easier for you to figure out the issue with this because I haven't really figured out why you are replacing the label class and label for description, although I am sure there is good reason :)

If you have multi language support activated there is no label for the description field (but I want to have one) and I want to add some padding.

So I check whether it's a multi language installation - but one line didn't make it into the right area. It's corrected :)

post-2759-0-30608500-1424558036_thumb.pn

Default: missing label and padding for description

  • Like 2
Link to comment
Share on other sites

  • 2 months later...

Hi,

I have built a gallery site and use ImageExtra to add some additional informations to the images. Everything works fine if I visit the page as a logged-in user, but if I have a look at the site as a (normal) guest, none of the extra fields are displayed.

I think this is a problem of missing access rights, but I did not find any point where to change it. The rights of the files on the server seem to be OK.

Any ideas?

Thanks

Günter

Edited by LostKobrakai
Merged with module support topic
Link to comment
Share on other sites

@biber

Hi,

just to make sure: you visit the page in the frontend? That means you do not see the text output if you are not logged in. Strange. Do you see the images? Or is everything missing? Could you (temporary) try to disable the module and use the built-in functionality including description. Just to make sure it depends on the module. 

Edited by LostKobrakai
Added @… to make the response clear after merging topics
Link to comment
Share on other sites

@formmailer: You do not missed something. It's not possible at the moment. I could imagine to add a checkbox in the module setting to enable markdown. Could you open an issue on github or send me a pull request? I've no time at the moment to implement this. Thanks.

Link to comment
Share on other sites

Hi,

thanks for your reply. Yes, it's right: I visit the page in the frontend. If nobody is logged in I can see the image and the 'description'-field, if I log in I can see the rest of the fields. I had a look at my database with phpMyAdmin, where I can find the table 'field_images' with all the fields and it looks OK.

btw.  Is there a possibility to change the order of the fields of the admin page (caption before description) and/or change the label of the fields at the admin page in dependence of the page. For example: page 'Menschen':  field_1 labelled 'Vorname', field_2 labelled 'Nachname' - page 'Pflanzen': field_1 labelled 'deutscher Name', field_2 labelled 'botanischer Name'. This should make it easier for users to add new pictures.

Link to comment
Share on other sites

@formmailer: You do not missed something. It's not possible at the moment. I could imagine to add a checkbox in the module setting to enable markdown. Could you open an issue on github or send me a pull request? I've no time at the moment to implement this. Thanks.

Hi!

Thank you for your reply!

I'll open en issue on Github. If I have time to fix it myself, I'll send you a pull request.

//Jasper

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

thanks for your reply. Yes, it's right: I visit the page in the frontend. If nobody is logged in I can see the image and the 'description'-field, if I log in I can see the rest of the fields. I had a look at my database with phpMyAdmin, where I can find the table 'field_images' with all the fields and it looks OK.

btw.  Is there a possibility to change the order of the fields of the admin page (caption before description) and/or change the label of the fields at the admin page in dependence of the page. For example: page 'Menschen':  field_1 labelled 'Vorname', field_2 labelled 'Nachname' - page 'Pflanzen': field_1 labelled 'deutscher Name', field_2 labelled 'botanischer Name'. This should make it easier for users to add new pictures.

Hi,

I found the solution for my problem by myself: I filled out the german sections of the fields and didn't realize that guests see the default (english) version. A simple click on >Admin >Access >Users >guest >Language >deutsch brought back my vanished items. :rolleyes:

Still remains my whish to change the order of the fields and to rename them at the admin page.

Thanks

Günter

Link to comment
Share on other sites

Sorry I don't have time at the moment to implement this. For translating the strings there is already an issue opened on github.

For me it isn't necessary to change the order of the fields. Try to leave the checkboxes blank and add caption (for example) in other fields. I know there is a hint Do not use `orientation`, `link` or `caption` in this list. I just tested it and it seems to work. I know this solves not the problem to rearrange link and orientation field. You can also open an issue on github  :) (or solve it on your own and send me a pull request ^_^ ).

Link to comment
Share on other sites

@ justb3a:

Thanks for your reply.

After I have found my mistake your module works fine for me. The other wishes are luxury problems and I have a lot to learn before I try to solve it on my own.

Günter

Link to comment
Share on other sites

  • 1 month later...

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
×
×
  • Create New...