Jump to content
justb3a

Module: Image Extra

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

Share this post


Link to post
Share on other sites

Seems like my wish came true...even without formally requesting it ;)  :-) 

I agree this is the way to go. Good job! 

  • Like 1

Share this post


Link to post
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?

  • Like 2

Share this post


Link to post
Share on other sites

Hey Bea,

this is so cool! You have released it!  ^-^  The Blog Post is nice too. ^-^

Share this post


Link to post
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 :-)

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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).

Share this post


Link to post
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?

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

Otherwise I will look at this next week...

  • Like 1

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Hi!

A great module, but I am wondering if it is possible to use html (or markdown) in the extra fields?

I tried this, but without luck. But I might have missed something. :)

/Jasper

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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.

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

Share this post


Link to post
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 ^_^ ).

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

hi thats awesome module. good job.

i want to know how i print the images orientation values?

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Gadgetto
      SnipWire - Snipcart integration for ProcessWire
      Snipcart is a powerful 3rd party, developer-first HTML/JavaScript shopping cart platform. SnipWire is the missing link between Snipcart and the content management framework ProcessWire.
      With SnipWire, you can quickly turn any ProcessWire site into a Snipcart online shop. The SnipWire plugin helps you to get your store up and running in no time. Detailed knowledge of the Snipcart system is not required.
      SnipWire is free and open source licensed under Mozilla Public License 2.0! A lot of work and effort has gone into development. It would be nice if you could donate an amount to support further development:

      Status update links (inside this thread) for SnipWire development
      2020-07-03 -- SnipWire 0.8.7 (beta) released! Fixes some small bugs and adds an indicator for TEST mode 2020-04-06 -- SnipWire 0.8.6 (beta) released! Adds support for Snipcart subscriptions and also fixes some problems 2020-03-21 -- SnipWire 0.8.5 (beta) released! Improves SnipWires webhooks interface and provides some other fixes and additions 2020-03-03 -- SnipWire 0.8.4 (beta) released! Improves compatibility for Windows based Systems. 2020-03-01 -- SnipWire 0.8.3 (beta) released! The installation and uninstallation process has been heavily revised. 2020-02-08 -- SnipWire 0.8.2 (beta) released! Added a feature to change the cart and catalogue currency by GET, POST or SESSION param 2020-02-03 -- SnipWire 0.8.1 (beta) released! All custom classes moved into their own namespaces. 2020-02-01 -- SnipWire is now available via ProcessWire's module directory! 2020-01-30 -- SnipWire 0.8.0 (beta) first public release! (module just submitted to the PW modules directory) 2020-01-28 -- added Custom Order Fields feature (first SnipWire release version is near!) 2020-01-21 -- Snipcart v3 - when will the new cart system be implemented? 2020-01-19 -- integrated taxes provider finished (+ very flexible shipping taxes handling) 2020-01-14 -- new date range picker, discount editor, order notifiactions, order statuses, and more ... 2019-11-15 -- orders filter, order details, download + resend invoices, refunds 2019-10-18 -- list filters, REST API improvements, new docs platform, and more ... 2019-08-08 -- dashboard interface, currency selector, managing Orders, Customers and Products, Added a WireTabs, refinded caching behavior 2019-06-15 -- taxes provider, shop templates update, multiCURL implementation, and more ... 2019-06-02 -- FieldtypeSnipWireTaxSelector 2019-05-25 -- SnipWire will be free and open source Plugin Key Features
      Fast and simple store setup Full integration of the Snipcart dashboard into the ProcessWire backend (no need to leave the ProcessWire admin area) Browse and manage orders, customers, discounts, abandoned carts, and more Multi currency support Custom order and cart fields Process refunds and send customer notifications from within the ProcessWire backend Process Abandoned Carts + sending messages to customers from within the ProcessWire backend Complete Snipcart webhooks integration (all events are hookable via ProcessWire hooks) Integrated taxes provider (which is more flexible then Snipcart own provider) Useful Links
      SnipWire in PW modules directory SnipWire Docs (please note that the documentation is a work in progress) SnipWire @GitHub (feature requests and suggestions for improvement are welcome - I also accept pull requests) Snipcart Website  

       
      ---- INITIAL POST FROM 2019-05-25 ----
       
    • By Sten
      Hello
      Till now I hacked something with the twig template but it works no more with new PW versions so I look forward to create a module. I am working on a site in multiple languages : French, English, Italian, German, Spanish, Portuguese, Hebrew, Russian. The new posts are entered in any language with a field for language. Till now, I got twig files to get the translations with constants defined for each part of the pages.
      So I'd like to create a module to include theses files added according to the url /fr/en/...
      Have you some observations to do before I begin about the direction to take ?
      Thank you
    • By ukyo
      Mystique Module for ProcessWire CMS/CMF
      Github repo : https://github.com/trk/Mystique
      Mystique module allow you to create dynamic fields and store dynamic fields data on database by using a config file.
      Requirements
      ProcessWire 3.0 or newer PHP 7.0 or newer FieldtypeMystique InputfieldMystique Installation
      Install the module from the modules directory:
      Via Composer:
      composer require trk/mystique Via git clone:
      cd your-processwire-project-folder/ cd site/modules/ git clone https://github.com/trk/Mystique.git Module in live reaction with your Mystique config file
      This mean if you remove a field from your config file, field will be removed from edit screen. As you see on youtube video.
      Using Mystique with your module or use different configs path, autoload need to be true for modules
      Default configs path is site/templates/configs/, and your config file name need to start with Mystique. and need to end with .php extension.
      Adding custom path not supporting anymore !
      // Add your custom path inside your module class`init` function, didn't tested outside public function init() { $path = __DIR__ . DIRECTORY_SEPARATOR . 'configs' . DIRECTORY_SEPARATOR; Mystique::add($path); } Mystique module will search site/modules/**/configs/Mystique.*.php and site/templates/Mystique.*.php paths for Mystique config files.
      All config files need to return a PHP ARRAY like examples.
      Usage almost same with ProcessWire Inputfield Api, only difference is set and showIf usage like on example.
      <?php namespace ProcessWire; /** * Resource : testing-mystique */ return [ 'title' => __('Testing Mystique'), 'fields' => [ 'text_field' => [ 'label' => __('You can use short named types'), 'description' => __('In file showIf working like example'), 'notes' => __('Also you can use $input->set() method'), 'type' => 'text', 'showIf' => [ 'another_text' => "=''" ], 'set' => [ 'showCount' => InputfieldText::showCountChars, 'maxlength' => 255 ], 'attr' => [ 'attr-foo' => 'bar', 'attr-bar' => 'foo' ] ], 'another_text' => [ 'label' => __('Another text field (default type is text)') ] ] ]; Example:
      site/templates/configs/Mystique.seo-fields.php <?php namespace ProcessWire; /** * Resource : seo-fields */ return [ 'title' => __('Seo fields'), 'fields' => [ 'window_title' => [ 'label' => __('Window title'), 'type' => Mystique::TEXT, // or InputfieldText 'useLanguages' => true, 'attr' => [ 'placeholder' => __('Enter a window title') ] ], 'navigation_title' => [ 'label' => __('Navigation title'), 'type' => Mystique::TEXT, // or InputfieldText 'useLanguages' => true, 'showIf' => [ 'window_title' => "!=''" ], 'attr' => [ 'placeholder' => __('Enter a navigation title') ] ], 'description' => [ 'label' => __('Description for search engines'), 'type' => Mystique::TEXTAREA, 'useLanguages' => true ], 'page_tpye' => [ 'label' => __('Type'), 'type' => Mystique::SELECT, 'options' => [ 'basic' => __('Basic page'), 'gallery' => __('Gallery'), 'blog' => __('Blog') ] ], 'show_on_nav' => [ 'label' => __('Display this page on navigation'), 'type' => Mystique::CHECKBOX ] ] ]; Searching data on Mystique field is limited. Because, Mystique saving data to database in json format. When you make search for Mystique field, operator not important. Operator will be changed with %= operator.
      Search example
      $navigationPages = pages()->find('my_mystique_field.show_on_nav=1'); $navigationPages = pages()->find('my_mystique_field.page_tpye=gallery');
    • By Robin S
      This is a module I made as an experiment a while ago and never got around to releasing publicly. At the time it was prompted by discussions around using Repeater fields for "page builder" purposes, where the depth feature could possibly be used for elements that would be nested inside other elements. I thought it would be useful to enforce some depth rules and translate the depth data into a multi-dimensional array structure.
      I'm not using this module anywhere myself but maybe it's useful to somebody.
      Repeater Depth Helper
      This module does two things relating to Repeater fields that have the "Item depth" option enabled:
      It enforces some depth rules for Repeater fields on save. Those rules are:
      The first item must have a depth of zero. Each item depth must not be more than one greater than previous item depth. It provides a RepeaterPageArray::getDepthStructure helper method that returns a nested depth structure for a Repeater field value.
      Helper method
      The module adds a RepeaterPageArray::getDepthStructure method that returns a multi-dimensional array where the key is the page ID and the value is an array of nested "child" items, or null if there are no nested children.
      Example

      The module doesn't make any assumptions about how you might want to use the depth structure array, but here is a way you might use it to output a nested unordered list.
      // Output a nested unordered list from a depth structure array function outputNestedList($depth_structure, $repeater_items) { $out = "<ul>"; foreach($depth_structure as $page_id => $nested_children) { $out .= "<li>" . $repeater_items->get("id=$page_id")->title; // Go recursive if there are nested children if(is_array($nested_children)) $out .= outputNestedList($nested_children, $repeater_items); $out .= "</li>"; } $out .= "</ul>"; return $out; } $repeater_items = $page->my_repeater; $depth_structure = $repeater_items->getDepthStructure(); echo outputNestedList($depth_structure, $repeater_items);
       
      https://github.com/Toutouwai/RepeaterDepthHelper
      https://modules.processwire.com/modules/repeater-depth-helper/
    • By MoritzLost
      Cacheable Placeholders
      This module allows you to have pieces of dynamic content inside cached output. This aims to solve the common problem of having a mostly cacheable site, but with pieces of dynamic output here and there.  Consider this simple example, where you want to output a custom greeting to the current user:
      <h1>Good morning, <?= ucfirst($user->name) ?></h1> This snippet means you can't use the template cache (at least for logged-in users), because each user has a different name. Even if 99% of your output is static, you can only cache the pieces that you know won't include this personal greeting. A more common example would be CSRF tokens for HTML forms - those need to be unique by definition, so you can't cache the form wholesale.
      This module solves this problem by introducing cacheable placeholders - small placeholder tokens that get replaced during every request. The replacement is done inside a Page::render hook so it runs during every request, even if the response is served from the template cache. So you can use something like this:
      <h1>Good morning, {{{greeting}}}</h1> Replacement tokens are defined with a callback function that produces the appropriate output and added to the module through a simple hook:
      // site/ready.php wire()->addHookAfter('CachePlaceholders::getTokens', function (HookEvent $e) { $tokens = $e->return; $tokens['greeting'] = [ 'callback' => function (array $tokenData) { return ucfirst(wire('user')->name); } ]; $e->return = $tokens; }); Tokens can also include parameters that are parsed and passed to the callback function. There are more fully annotated examples and step-by-step instructions in the README on Github!
      Features
      A simple and fast token parser that calls the appropriate callback and runs automatically. Tokens may include multiple named or positional parameters, as well as multi-value parameters. A manual mode that allows you to replace tokens in custom pieces of cached content (useful if you're using the $cache API). Some built-in tokens for common use-cases: CSRF-Tokens, replacing values from superglobals and producing random hexadecimal strings. The token format is completely customizable, all delimiters can be changed to avoid collisions with existing tag parsers or template languages. Links
      Github Repository & documentation Module directory If you are interested in learning more, the README is very extensive, with more usage examples, code samples and usage instructions!
×
×
  • Create New...