Jump to content
justb3a

Module: Image Extra

Recommended Posts

@tekno: Like any other value: $image->orientation
 
For example:

$sidebar = "<img src='$image->url' alt='$image->description' class='$image->orientation' />";

outputs:

<img src="/site/assets/files/1/bigger-terminal.400x0.jpg" alt="We're gonna need a bigger terminal." class="left">

Share this post


Link to post
Share on other sites

i tried ->orientation , ->orientationField , ->orientationValues but it did not print. i try it again

thanks for your reply

Share this post


Link to post
Share on other sites

It also works for just one image. If you allow more than one image in field settings you have to get the first image, iterate over or get one randomly. 

// $image = $page->images->getRandom();
// foreach ($page->images as $image) { ... }
$image = $page->images->first();

$sidebar = "<img src='$image->url' alt='$image->description' class='$image->orientation' />";
  • Like 1

Share this post


Link to post
Share on other sites

thank you it works great

how can i translate image standart fields (orientation, description, caption)? i look ImageExtra.module but i can not dare to change anything :)

Share this post


Link to post
Share on other sites

There is already an issue on github. I'll get back to this as soon as I've resolved some other issues...

Share this post


Link to post
Share on other sites

Thanks very much @justb3a for this module, a valuable addition to PW and looks ideal for solving a usability + presentation requirement I have :)

I can see from your blog page how to access the additional attributes via the API and have that working AOK in a template but for an image inserted in a textarea field that uses CkEditor do you know how I can get CkEditor or PW to output the extra attribute I have added? Thanks in advance for any pointers or help :)

Share this post


Link to post
Share on other sites

This is just what I was looking for! 

I have a question, though: How might I go about changing one of the custom fields to a textarea, or even enabling CKEditor?

Share this post


Link to post
Share on other sites

@alan: Sorry I never want to output extra attributes in CkEditor or similar. If you find a solution, please let me know.  :)

@statestreet: This is not possible at the moment, but I've planned to allow markdown in the fields.

Share this post


Link to post
Share on other sites

@justb3a

Sorry I never want to output extra attributes in CkEditor or similar. If you find a solution, please let me know.   :)

Thanks, I'm glad to know this facility is not something I missed :)

I will certainly let you know if I find a solution.

Share this post


Link to post
Share on other sites

Great module, worked fine for me! But since a couple of days, for any reason, it doubles my costum image fields. Updated it to Version 0.0.3 but still the same problem. I dont know what happened. Maybe i did anything wrong? I didn't install any other module in the past days, as far as I know :D.

Here are some screenshots to show you what I mean:

http://www.directupload.net/file/d/4071/vtafnu3t_jpg.htm
http://www.directupload.net/file/d/4071/n592lj7s_jpg.htm  

        

Any ideas what could be wrong?

Thank you!

  • Like 1

Share this post


Link to post
Share on other sites

Great module, worked fine for me! But since a couple of days, for any reason, it doubles my costum image fields. Updated it to Version 0.0.3 but still the same problem. I dont know what happened. Maybe i did anything wrong? I didn't install any other module in the past days, as far as I know :D.

Here are some screenshots to show you what I mean:

http://www.directupload.net/file/d/4071/vtafnu3t_jpg.htm

http://www.directupload.net/file/d/4071/n592lj7s_jpg.htm  

        

Any ideas what could be wrong?

Thank you!

Okay, somehow there seems to be a problem with LanguageSupport and the german package, I uninstalled it and its working perfectly now. Could be a bug or I did anything wrong.

Share this post


Link to post
Share on other sites

This is just a JavaScript/CSS issue. Go to Modules > Core and install the Languages Support - Tabs module.  ;) 

  • Like 1

Share this post


Link to post
Share on other sites

Hi @justb3a,

Just noticed a bit of a critical bug. If you remove one of the "Add other text input fields" the field/column is not removed from the DB. This results in a fatal error and the images uploaded to the field are lost. You have to manually edit the DB table to remove the fields to get things working again.

As a wishlist item, I'd love to see the ability to add select, radio, and checkbox fields as well as plain text :)

Share this post


Link to post
Share on other sites

Hi @adrian,

initially I decided to keep the fields/columns after removing so if you need them again your data/entries are still available. I tested it again right now without any problems. 

Scenario: image field containing 4 image extra text fields, adding some images, removing one text field, editing/adding/deleting images... everything works as expected. Any ideas? (ProcessWire 2.6.22, PHP 5.6.14)

Share this post


Link to post
Share on other sites

Sorry for the delay in getting back to you regarding the error - I still need to look at this again, but for now I have a new problem for you :)

It looks like the Page Link option isn't working properly - it just shows a text input with "0" as the value.

post-985-0-74699000-1447329625_thumb.png

If I load "InputfieldPageListSelect.min.js" in the module, then it works as expected.

post-985-0-28869900-1447329642_thumb.png

Share this post


Link to post
Share on other sites

Another critical issue - when using an image extra field within a PageTable, the extra fields show up under the image and appear to be editable. You can make changes to the content of these fields, but of course they don't get saved when saving the main page which is very confusing for the user.

post-985-0-68439200-1447627272_thumb.png

  • Like 1

Share this post


Link to post
Share on other sites

Hi @adrian,

initially I decided to keep the fields/columns after removing so if you need them again your data/entries are still available. I tested it again right now without any problems. 

Scenario: image field containing 4 image extra text fields, adding some images, removing one text field, editing/adding/deleting images... everything works as expected. Any ideas? (ProcessWire 2.6.22, PHP 5.6.14)

Some more info on that error:

post-985-0-72466900-1447628132_thumb.png

The error is coming from PW itself because it looks like every DB field needs a value for the entry to be successfully saved. You should be able to replicate by removing one of the fields from the comma separated list of extra fields, or by simply uninstalling image extra and then trying to upload an image.

Share this post


Link to post
Share on other sites

Some more info on that error:

attachicon.gifScreen Shot 2015-11-16 at 8.54.52 AM.png

The error is coming from PW itself because it looks like every DB field needs a value for the entry to be successfully saved. You should be able to replicate by removing one of the fields from the comma separated list of extra fields, or by simply uninstalling image extra and then trying to upload an image.

I'm not able to reproduce this behaviour, I'll let the pictures speak for themselves:

  1. added 5 Image Extra fields, added images, filled content, saved
  2. removed 2 Image Extra fields
  3. added one more image
  4. saved page
  5. deinstalled module Image Extra
  6. edit page
  7. added another image, fill description
  8. save page

post-2759-0-64981300-1448018514_thumb.pn

Share this post


Link to post
Share on other sites

:) But I'm able to reproduce the PageLink issue:

post-2759-0-97446400-1448019794_thumb.pn

I'll fix that.

Regarding the PageTable issue: I never used an image field containing extra fields inside a PageTable. I'll test this later.

Share this post


Link to post
Share on other sites

I don't know what to say about the issue with removing extra fields - I am continuing to get that error on different PW installs.
 
But now I have another issue for you. With ImageExtra installed and Maximum Files Allowed set to "1" when I go to upload a second image, the editor actually shows both images. After save, the first one disappears, but without ImageExtra, the second one instantly overwrites the first one. This has been confusing for our users - they think a second image has been uploaded rather than overwriting the first one. I hope you can reproduce at your end.
 
I wonder if it's a simple matter of incorporating some of the new code in: 
https://github.com/ryancramerdesign/ProcessWire/blob/980ce4f0be2054dfbad4a7b334d35bdca42da7da/wire/modules/Inputfield/InputfieldFile/InputfieldFile.module#L438

into your module at:

https://github.com/justonestep/processwire-imageextra/blob/master/ImageExtra.module#L540

 
Thanks!

Share this post


Link to post
Share on other sites

Sorry, I am on a bit of a roll - I really do love this module :)

I don't really understand the "Select the inputfields where the extra fields should be attached." option in the config settings. It lists all the different inputfield types, but the module only works with image field types. I actually tried to see if it works with InputfieldFile, but it didn't even work there. Am I missing something about this setting?

I think a more useful setting would be to control which image fields (the actual fields, not field types) that imageextra is attached to. At the moment the "Image Extra Fields" fieldset is added to the Input tab of all image fields, which I expect most developers don't need - they probably only want them for certain image fields. Does that make sense and sound like a good idea?

Thanks again :)

Share this post


Link to post
Share on other sites

@adrian: Could you please open an issue for each topic on Github?

The select field in module settings allows you to add these extra fields to other ImageFields (for example CroppableImage). I've never tested it with InputfieldFile but I think this should be supported as well.

There could be an additional select list to choose the fields (only list the fields with FieldTypes selected above) but I don't know if this is really necessary. Imagine you add another image field where you want to add extra fields, you had to go to module settings again and select the newly added field. If you don't need it for an image field, just don't touch the settings.  

  • Like 1

Share this post


Link to post
Share on other sites

Hello,

How do you add "InputfieldPageListSelect.min.js" to the module to fix the 0 issue with the link field? 

Ive tried hooking into the "InputfieldPageListSelect::render" but couldnt get it to work.

  • Like 1

Share this post


Link to post
Share on other sites

Hello,

How do you add "InputfieldPageListSelect.min.js" to the module to fix the 0 issue with the link field? 

Ive tried hooking into the "InputfieldPageListSelect::render" but couldnt get it to work.

I think I just modified the ImageExtra module to add it there. Have a go and if you are still having trouble I'll take a closer look.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Robin S
      After forgetting the class name of the wonderful AdminPageFieldEditLinks module for what feels like the 100th time I decided I needed to give my failing memory a helping hand...
      Autocomplete Module Class Name
      Provides class name autocomplete suggestions for the "Add Module From Directory" field at Modules > New.
      Requires ProcessWire >= v3.0.16.
      Screencast

      Installation
      Install the Autocomplete Module Class Name module.
      Configuration
      Choose the type of autocomplete options list: "Module class names from directory" or "Custom list of module class names". The latter could be useful if you regularly install some modules and would prefer a shorter list of autocomplete suggestions. The list of class names in the modules directory is generated when the Autocomplete Module Class Name module is installed. It doesn't update automatically (because the retrieval of the class names is quite slow), but you can use the button underneath when you want to retrieve an updated list of class names from the directory. The "fuzzy search" option uses custom filter and item functions for Awesomplete so that the characters you type just have to exist in the module class name and occur after preceding matches but do not need to be contiguous. Uncheck this option if you prefer the standard Awesomplete matching. Custom settings for Awesomplete can be entered in the "Awesomplete options" field if needed. See the Awesomplete documentation for more information.  
      https://github.com/Toutouwai/AutocompleteModuleClassName
      https://modules.processwire.com/modules/autocomplete-module-class-name/
    • By teppo
      MarkupMenu is a markup module for generating menu trees. When provided a root page as a starting point, it generates a navigation tree (by default as a HTML "<ul>" element wrapped by a "<nav>" element) from that point onwards. If you've also provided it with current (active) page, the menu will be rendered accordingly, with current item highlighted and items rendered up to that item and its children (unless you disable the "collapsed" option, in which case the full page tree will be rendered instead).
      Modules directory: https://modules.processwire.com/modules/markup-menu/ GitHub repository: https://github.com/teppokoivula/MarkupMenu Usage
      As a markup module, MarkupMenu is intended for front-end use, but you can of course use it in a module as well. Typically you'll only need the render() method, which takes an array of options as its only argument:
      echo $modules->get('MarkupMenu')->render([ 'root_page' => $pages->get(1), 'current_page' => $page, ]); Note: if you omit root_page, site root page is used by default. If you omit current_page, the menu will be rendered, but current (active) page won't be highlighted etc.
      A slightly more complex example, based on what I'm using on one of my own sites to render a (single-level) top menu:
      echo $modules->get('MarkupMenu')->render([ 'current_page' => $page, 'templates' => [ 'nav' => '<nav class="{classes} menu--{menu_class_modifier}" aria-label="{aria_label}">%s</nav>', 'item_current' => '<a class="menu__item menu__item--current" href="{item.url}" tabindex="0" aria-label="Current page: {item.title}">{item.title}</a>', ], 'placeholders' => [ 'menu_class_modifier' => 'top', 'aria_label' => 'Main navigation', ], 'include' => [ 'root_page' => true, ], 'exclude' => [ 'level_greater_than' => 1, ], ]); Note: some things you see above may not be entirely sensible, such as the use of {menu_class_modifier} and {aria_label} placeholders. On the actual site the "nav" template is defined in site config, so I can define just these parts on a case-by-case basis while actual nav markup is maintained in one place.
      Please check out the README file for available render options. I'd very much prefer not to keep this list up to date in multiple places. Basically there are settings for defining "templates" for different parts of the menu (list, item, etc.), include array for defining rules for including in the menu and exclude array for the opposite effect, classes and placeholders arrays for overriding default classes and injecting custom placeholders, etc. 🙂
      MarkupMenu vs. MarkupSimpleNavigation
      TL;DR: this is another take on the same concept. There are many similarities, but also some differences – especially when it comes to the supported options and syntax. If you're currently using MarkupSimpleNavigation then there's probably no reason to switch over.
      I'd be surprised if anyone didn't draw lines between this module and Soma's awesome MarkupSimpleNavigation. Simply put, I've been using MSN (...) for a number of years, and it's been great – but there have been some smallish issues with it, particularly with the markup generation part, and it's also doing some things in a way that just doesn't work for me – the xtemplates thing being one of these. In many ways it's less about features, and more about style.
      In MarkupMenu I've tried to correct these little hiccups, modernise the default markup, and allow for more flexibility with placeholder variables and additional / different options. MarkupMenu was built for ProcessWire 3.0.112+ and PHP 7.1+, it's installable with Composer, and I have a few additional ideas (such as conditional placeholders) on my todo list.
      One smallish and rather specific difference is that MarkupMenu supports overriding default options via $config->MarkupMenu. I find myself redefining the default markup for every site, which until now meant that each site has a wrapper function for MarkupSimpleNavigation (to avoid code / config repetition), and this way I've been able to omit that 🙂
      Requirements
      ProcessWire >= 3.0.112 PHP >= 7.1.0 If you're working on an earlier version of ProcessWire or PHP, use MarkupSimpleNavigation instead.
    • By Robin S
      Repeater Images
      Adds options to modify Repeater fields to make them convenient for "page-per-image" usage. Using a page-per-image approach allows for additional fields to be associated with each image, to record things such as photographer, date, license, links, etc.
      When Repeater Images is enabled for a Repeater field the module changes the appearance of the Repeater inputfield to be similar (but not identical) to an Images field. The collapsed view shows a thumbnail for each Repeater item, and items can be expanded for field editing.
      Screencast

      Installation
      Install the Repeater Images module.
      Setup
      Create an image field to use in the Repeater field. Recommended settings for the image field are "Maximum files allowed" set to 1 and "Formatted value" set to "Single item (null if empty)". Create a Repeater field. Add the image field to the Repeater. If you want additional fields in the Repeater create and add these also. Repeater Images configuration
      Tick the "Activate Repeater Images for this Repeater field" checkbox. In the "Image field within Repeater" dropdown select the single image field. You must save the Repeater field settings to see any newly added Image fields in the dropdown. Adjust the image thumbnail height if you want (unlike the core Images field there is no slider to change thumbnail height within Page Edit). Note: the depth option for Repeater fields is not compatible with the Repeater Images module.
      Image uploads feature
      There is a checkbox to activate image uploads. This feature allows users to quickly and easily add images to the Repeater Images field by uploading them to an adjacent "upload" field.
      To use this feature you must add the image field selected in the Repeater Images config to the template of the page containing the Repeater Images field - immediately above or below the Repeater Images field would be a good position.
      It's recommended to set the label for this field in template context to "Upload images" or similar, and set the visibility of the field to "Closed" so that it takes up less room when it's not being used. Note that when you drag images to a closed Images field it will automatically open. You don't need to worry about the "Maximum files allowed" setting because the Repeater Images module overrides this for the upload field.
      New Repeater items will be created from the images uploaded to the upload field when the page is saved. The user can add descriptions and tags to the images while they are still in the upload field and these will be retained in the Repeater items. Images are automatically deleted from the upload field when the page is saved.
      Tips
      The "Use accordion mode?" option in the Repeater field settings is useful for keeping the inputfield compact, with only one image item open for editing at a time. The "Repeater item labels" setting determines what is shown in the thumbnail overlay on hover. Example for an image field named "image": {image.basename} ({image.width}x{image.height})  
      https://github.com/Toutouwai/RepeaterImages
      https://modules.processwire.com/modules/repeater-images/
    • By EyeDentify
      Hello There Guys.

      I am in the process of getting into making my first modules for PW and i had a question for you PHP and PW gurus in here.

      I was wondering how i could use an external library, lets say TwitterOAuth in my PW module.
      Link to library
      https://twitteroauth.com/

      Would the code below be correct or how would i go about this:
      <?PHP namespace ProcessWire; /* load the TwitterOAuth library from my Module folder */ require "twitteroauth/autoload.php"; use Abraham\TwitterOAuth\TwitterOAuth; class EyeTwitter extends WireData,TwitterOAuth implements Module { /* vars */ protected $twConnection; /* extend parent TwitterOAuth contructor $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token, $access_token_secret); */ public function myTwitterConnection ($consumer_key, $consumer_secret, $access_token, $access_token_secret) { /* save the connection for use later */ $this->twConnection = TwitterOAuth::__construct($consumer_key, $consumer_secret, $access_token, $access_token_secret); } } ?> Am i on the right trail here or i am barking up the wrong tree?
      I don´t need a complete solution, i just wonder if i am including the external library the right way.
      If not, then give me a few hint´s and i will figure it out.

      Thanks a bunch.

      /EyeDentify
    • By dimitrios
      Hello,
      this module can publish content of a Processwire page on a Facebook page, triggered by saving the Processwire page.
      To set it up, configure the module with a Facebook app ID, secret and a Page ID. Following is additional configuration on Facebook for developers:
      Minimum Required Facebook App configuration:
      on Settings -> Basics, provide the App Domains, provide the Site URL, on Settings -> Advanced, set the API version (has been tested up to v3.3), add Product: Facebook Login, on Facebook Login -> Settings, set Client OAuth Login: Yes, set Web OAuth Login: Yes, set Enforce HTTPS: Yes, add "http://www.example.com/processwire/page/" to field Valid OAuth Redirect URIs. This module is configurable as follows:
      Templates: posts can take place only for pages with the defined templates. On/Off switch: specify a checkbox field that will not allow the post if checked. Specify a message and/or an image for the post.
      Usage
      edit the desired PW page and save; it will post right after the initial Facebook log in and permission granting. After that, an access token is kept.
       
      Download
      PW module directory: http://modules.processwire.com/modules/auto-fb-post/ Github: https://github.com/kastrind/AutoFbPost   Note: Facebook SDK for PHP is utilized.


×
×
  • Create New...