theo

ImagePicker Field

Recommended Posts

- You can organize your images the way you want and not necessarily per page / repeater-item. For example using Media Library.

- You can access the same image from different pages. No need to upload it several times.

This can be done in CKEditor, but there was no single field type for this.

One example is a repeater for an image-carousel. You can now put all the images in a Media Page called e.g. "Carousel" and then just pick them up in the repeater's ImagePicker.

- You can also fill in an external Image URL and you will see a preview in the backend.

- You can have an overview of all images in all pages of your site. (Not in Repeaters and Pagetables though)

- Website admins can give backend users (editors) a predefined set of images for a certain field which they can choose from by defining selectors.

- Picking up images is fast with ImagePicker. ;)

 

Thank you.

  • Like 2

Share this post


Link to post
Share on other sites
14 minutes ago, adrianmak said:

how to pick up for multiple images?

You need a repeater then.

Share this post


Link to post
Share on other sites

Wow @theo I like very much!! This work perfectly with Media Library!! I think a lot of people will benefit from it, so, thanks you a lot!! 

About some possible changes, honestly I do not see. Yes multiple images could be good but not essential, it's possible use the Repeater Field. Maybe could better when click on in the image, instead of the link to the media, have the possible to delate the image or have the box for edit the image. But I think this will be more difficult because in this way needs also save the new image and not edit the original.

But anyway this module is very very helpful! Thank you again! :)

 

  • Like 1

Share this post


Link to post
Share on other sites

Hi Guys, I have a little problem, this module it's possible use only with the Super Admin User, is it possible set it also for other user? Thank you

Btw I use a lot this modulo In combination with the Media Library! it's very great!

Share this post


Link to post
Share on other sites
23 hours ago, MarcoPLY said:

Hi Guys, I have a little problem, this module it's possible use only with the Super Admin User, is it possible set it also for other user? Thank you

Btw I use a lot this modulo In combination with the Media Library! it's very great!

Hello Marco: in the code there is no instruction for restrict the field only to super user...
What happens for a no super admin?

Share this post


Link to post
Share on other sites

Hi @abmcr,  if you are not super admin when you click on the button to pick the image it opens a windows with Media Files page like you are in the page, so you ca not choose the file to add but you can edit it. 

Share this post


Link to post
Share on other sites

Yes, it probably has to do with the fact, that the page generating the picker list uses an admin template.

The page is in Admin->Setup->Image Picker List.

I have almost no time atm.

Can anybody explain how to make such pages accessible for non superusers?

Thank you.

Share this post


Link to post
Share on other sites

@MarcoPLY

Can you test this?

In ImagePickerList.module (should be in site/modules/ImagePicker/)

Add 'permission' => 'imagepicker' to the getModuleInfo() block

    public static function getModuleInfo() {
        return array(
            'title' => 'ImagePicker Lister',
            'version' => 90,
            'summary' => 'ImagePicker Lister',
            'singular' => true,
            'autoload' => false,
            'permission' => 'imagepicker'
        );
    }

Then as admin in the backend do:

Access -> Permissions -> Add New:

Name: imagepicker

After saving, give it a title like "Image Picker".

Then add this permission to your editor role (Acesss -> Roles).

Try if it works. Maybe you have to log-out and in and refresh modules (Modules->Refresh).

 

  • Like 1

Share this post


Link to post
Share on other sites

Hi, 

I have a problem to use the size api for resize the images. 

This is an example of my situation:

<?php $features = $pages->find("template=single-design"); ?>
	<?php foreach($features as $product): ?>
		<?php
			$image_big = $product->image_card;
			$image_right = $image_big->size(250,250); // this give me error "call to a member funtion size() on null"
		?>
			<img src="<?= $image_right ?>"> <!-- If I use $image_big the images show up correctly -->
	<?php endforeach; ?>

What I can do for resize the images?

 

I also have try to use the api like in the manual 👇 - But if I use url the images never show up, also first() doesn't work. 

$image = $page->images->first();
$thumb = $image->size(100, 100)
echo "<img src='$thumb->url'>"

 

Share this post


Link to post
Share on other sites

Sorry @theo 😓! I don't know way I looking in all forums but not in your documentation!! sorry! 

btw post the answer here just if some one will need:

<?php $features = $pages->find("template=single-design"); ?>
	<?php foreach($features as $product): ?>
		<?php
			$image_big = $product->getInputField('image_card')->getImage(); 
			$image_right = $image_big->size(250,250);
		?>
			<img src="<?= $image_right->url ?>"> 
	<?php endforeach; ?>

 

  • Like 1

Share this post


Link to post
Share on other sites

Hi @theo

Do have you ever tried to use api for get the url in a multi language website? Because I notice a problem with the code above. maybe I wrong something, the problem is only when I use a different language.  At moment If I switch to the second language I see the error page with this error:  "Call to a member function width() on null" or size()

Do you know why? What did I do wrong?

 

 

Share this post


Link to post
Share on other sites

@MarcoPLY

I have no idea. I've never used it in this way (resizing the linked image).

Can you try to see what's going wrong? I've no time atm.

Thank you!

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 Soma
      LogMaintenance
      A simple ProcessWire module to give some maintenance control over log files. I found myself often having lots of log files for different things that can grow more or less quickly to a size where they can be difficult to maintain. The built in Logger of PW does a good job of giving you the possibility to delete or prune logs. But it has to be done manually and sometimes a log grows into millions of lines, which makes it often impossible to even prune it as it's too large.
      LogMaintenance uses LazyCron to run the maintenance task and there's several settings you can setup on a global or per log basis.
      Archive: will create zip files for each log file in logs/archive/ folder and add the log each time the maintenance is run to a subfolder containing the datetime.
      Lines: keeps logs to a certain number of lines 
      Days: keeps the log to a certain number of days
      Bytes: keeps the log to a certain amount of bytes
      Each setting is checked from top down, the first setting to contain something is used. So if you check the "Archive" option, all other settings are ignored and logs are archived everytime the LazyCron is executed. If you want to keep your logs to a certain amount of bytes just leave all other settings to 0 or blank.
      Per Log Settings
      There's a textarea that you can use to setup a config for a specific log file one per line. All the logs you define here ignore the global settings above. The syntax for the settings is:
      logname:[archive]:[lines]:[days]:[bytes] 
      errors:1:0:0:0 // would archive the errors log messages:0:10000:0:0 // will prune the errors log to 10000 lines  
      The module can be found on github for you to check out. It's still fresh and I'm currently testing.
      https://github.com/somatonic/LogMaintenance
    • By chcs
      After running this code in my module's __install() the template_id is not set. Any ideas why?  (The export contents from the template created and the one that I built with Admin are the same. Both exports have the template_id is set to mm_state. When I go to edit the field in Admin, the template is not showing on the Input tab and it doesn't show the template title on a page using the template that uses this field. Using processwire 3.0.98)

      // mm_state
      $field = $this->fields->get('mm_state');
      if (!@$field->id) $field = new Field();
      $field->type = $this->modules->get("FieldtypePage");
      $field->name = 'mm_state';
      $field->label = 'State';
      $field->derefAsPage = 2;
      $field->inputfield = "InputfieldSelect";
      $this->fields->save($field);
      $field->labelFieldName = 'title';
      $field->template_id = 'mm_state';
      $field->columnWidth = 100;
      $field->required = true;
      $this->fields->save($field);
    • By teppo
      Fieldtype Page IDs is a third party Fieldtype that, simply put, stores Page references as integers (Page IDs).
      This fieldtype was built as a quick and dirty workaround for Page Reference fields' inability handle self-references due to circular reference issues. A project I've been working on for a while now includes a combination of RepeaterMatrix content blocks and tagging/categorization system that would've resulted in a lot of duplicate pages (and plenty of unnecessary manual work for content editors) had I used built-in Page Reference fields, and thus a new Fieldtype felt like the most sensible approach.
      Fieldtype Page IDs was designed to be loosely compatible with Page References in order to make conversions between the two feasible, but it is quite limited feature wise:
      largely due to the fact that stored values are actually just integers with no connection to Pages whatsoever some advanced selectors and related features are not supported, and page values can't be directly accessed configuration settings are limited to the bare essentials (selector string and Inputfield class) only a handful of Inputfields (AsmSelect, Checkboxes, Text) are (currently) supported Anyway, in case you need to store Page IDs (and Page IDs only) and are happy with the limitations mentioned above, feel free to give this Fieldtype a try. It has been working fine for me in one particular project, but hasn't been tested that much, so please tread carefully – and let me know if you run into any issues.
      GitHub repository: https://github.com/teppokoivula/FieldtypePageIDs
      Modules directory: https://modules.processwire.com/modules/fieldtype-page-ids/
    • By daniels
      This is a lightweight alternative to other newsletter & newsletter-subscription modules.
      You can find the Module in the Modules directory and on Github
      It can subscribe, update, unsubscribe & delete a user in a list in Mailchimp with MailChimp API 3.0. It does not provide any forms or validation, so you can feel free to use your own. To protect your users, it does not save any user data in logs or sends them to an admin.
      This module fits your needs if you...
      ...use Mailchimp as your newsletter / email-automation tool ...want to let users subscribe to your newsletter on your website ...want to use your own form, validation and messages (with or without the wire forms) ...don't want any personal user data saved in any way in your ProcessWire environment (cf. EU data regulation terms) ...like to subscribe, update, unsubscribe or delete users to/from different lists ...like the Mailchimp UI for creating / sending / reviewing email campaigns *I have only tested it with PHP 7.x so far, so use on owners risk
      EDIT:
      I've updated the module to 0.0.4. I removed the instructions from this forum, so I don't have to maintain it on multiple places. Just checkout the readme on github 🙂
      If you have questions or like to contribute, just post a reply or create an issue or pr on github. 
    • By bernhard
      WHY?
      This module was built to fill the gap between simple $pages->find() operations and complex SQL queries.
      The problem with $pages->find() is that it loads all pages into memory and that can be a problem when querying multiple thousands of pages. Even $pages->findMany() loads all pages into memory and therefore is a lot slower than regular SQL.
      The problem with SQL on the other hand is, that the queries are quite complex to build. All fields are separate tables, some repeatable fields use multiple rows for their content that belong to only one single page, you always need to check for the page status (which is not necessary on regular find() operations and therefore nobody is used to that).
      In short: It is far too much work to efficiently and easily get an array of data based on PW pages and fields and I need that a lot for my RockGrid module to build all kinds of tabular data.

      Basic Usage

       
      Docs & Download
      https://modules.processwire.com/modules/rock-finder/
      https://gitlab.com/baumrock/RockFinder/tree/master
       
      Changelog
      180528, v1.0.4 add custom select statement option 180516 change sql query method, bump version to 1.0.0 180515 multilang bugfix 180513 beta release <180513 preview/discussion took place here: https://processwire.com/talk/topic/18983-rocksqlfinder-highly-efficient-and-flexible-sql-finder-module/