Jump to content
apeisa

Release: Thumbnails

Recommended Posts

I wonder about change configuration to the JSON format.

In this way, we could provide more options for the site administrator. But the configuration becomes more difficult :/


[
  {
     "name": "my new thumb",
     "template": [ "basic-page", "home" ],
     "aspectRatio": 1,
     "minSize": [100,100],
     "maxSize": [  200,200 ]
  },
  {
     "name": "small thumb",
     "aspectRatio": null
  },
  {
     "name": "thumbnail2",
     "width": 100,
     "height": 200
  }
]

What do you think about this?

Share this post


Link to post
Share on other sites

I do like the idea of Min and max size as it is currently possible to create a small crop that is actually enlarged on the site.

I'll have a think about config later and see if I can come up with a suggestion.

Share this post


Link to post
Share on other sites

I do like the idea of Min and max size as it is currently possible to create a small crop that is actually enlarged on the site.

This is something else.

jCrop Documentation

jCrop allows you to specify the dimensions of graphics that you cut.

You can allow for example 100x200px MIN or 100x500px MAX for images in siebar. This way you can cut the picture of a different height but fixed width 100px.

Share this post


Link to post
Share on other sites

Back when I played with it a few years ago, you could set the crop box to be the actual crop size (so if you uploaded a 1600x1280 image and your image is to be cropped to 320x200, it can give you a starting box that size that you can't make any smaller, but could make bigger proportionally - that's what I was talking about (although I suspect you already worked that out ;)).

If accidentally uploading images that are smaller than the crop the crop box could just scale down so it uses up as much of the image as possible or something.

Just an idea - it all works fine as it is and I'm looking forward to playing with the per-field settings later today/tomorrow :) Just out of interest, to the per-field settings work in the new per-template settings that ryan introduced recently for things like naming the same field differently for different templates? Being able to have just one "images" field and set the settings for that field in the many templates I use it in would be awesome :)

Share this post


Link to post
Share on other sites

If accidentally uploading images that are smaller than the crop the crop box could just scale down so it uses up as much of the image as possible or something.

I think we should have "Min Image Dimensions" as we have "Max ImageDimensions". You should get a message that the image is too small.

Just an idea - it all works fine as it is and I'm looking forward to playing with the per-field settings later today/tomorrow :) Just out of interest, to the per-field settings work in the new per-template settings that ryan introduced recently for things like naming the same field differently for different templates? Being able to have just one "images" field and set the settings for that field in the many templates I use it in would be awesome :)

I looked at these new features and I do not think it was possible for now.

I do not know how to add a field to be visible in chosen context. Maybe Ryan knows how :].

But you can do this right now in this way:

thumbnail,200,200,basic-page,home
big_thumbnail,500,500,other_template_name
medium_thumbnail,300,300,post_template

Share this post


Link to post
Share on other sites

I wonder about change configuration to the JSON format.

In this way, we could provide more options for the site administrator. But the configuration becomes more difficult :/

Well, if we keep adding options, then JSON is soon much easier than current method :)

Also, if we ever build nicer UI, then JSON is much easier to have at backend than our current method. Also we might think about using YAML, since that is pretty nice to look at and write, but not sure. Seems simpler to go with JSON.

PS: Thanks for the pull request. I will test and merge it soon.

Share this post


Link to post
Share on other sites

Also, if we ever build nicer UI, then JSON is much easier to have at backend than our current method. Also we might think about using YAML, since that is pretty nice to look at and write, but not sure.

I would totally go with YAML Parsing here :) There is also a neon, which looks like some sort of 'YAML' with few fixes. Are you interested in YAML? I'm thinking about creating a module, which would some more advanced configuration (I'll talk about it more later, when at least readme would be done:) ), So I'm thinking we could do module named e.g. 'CodeYAML', which would add support for YAML parsing (so you would not have to parse it manually in code or distribute it, you'd have only one dependency). What do you think?

Share this post


Link to post
Share on other sites

Also we might think about using YAML, since that is pretty nice to look at and write, but not sure.

Hi,

A thought on YAML: whilst it is a very nice format (I use it for test fixtures) please be aware that it is whitespace intolerant as it uses leading indentation/spacing to delimit structures a bit like Python or HAML do. You need to configure your editor carefully to preserve existing leading space if you are to work with YAML files. If it is just you going to be editing these then that might not be a problem, but once users of your system start editing them you could be in for some extra support work if they don't configure their editors well.

I've used a single file library called spyc before and found it very effective at meeting my YAML processing needs.

Share this post


Link to post
Share on other sites

A thought on YAML: whilst it is a very nice format (I use it for test fixtures) please be aware that it is whitespace intolerant as it uses leading indentation/spacing to delimit structures a bit like Python or HAML do.

It also doesn't support tabs, AFAIK - that's why I mentioned neon (if you like YAML, neon seems the way to go):

NEON is very similar to YAML.The main difference is that the NEON supports "entities" (so can be used e.g. to parse phpDoc annotations) and tab characters for indentation. NEON syntax is a little simpler and the parsing is faster.

Share this post


Link to post
Share on other sites

Hi Adam,

Sorry, I totally blanked on your initial reply to apeisa so I missed your link to Neon. I'll check it out.

Ok, took a look and you're right. Neon looks more flexible regarding leading tabs / spaces but lacks a lot of YAMLs more complex features -- which may well be fine for this application -- and it gives you good error reports. However, I think my general point may still hold true if people who aren't familiar with the leading whitespace requirements end up editing those files, and especially if the parser errors are not exposed fully to the user.

Edited by netcarver

Share this post


Link to post
Share on other sites
Just out of interest, to the per-field settings work in the new per-template settings that ryan introduced recently for things like naming the same field differently for different templates?

With the new field-template context, you can name it differently with labels and descriptions. But changing the actual 'name' of a field is something you can't do. Though even if we could, I think I might find that a bit confusing. :)

Being able to have just one "images" field and set the settings for that field in the many templates I use it in would be awesome

Being able to change the other field settings (beyond label, description, columnWidth, visibility) is actually supported in the core, but I've got the system blocking it right now because I'm worried about side effects here. I figured we'd open this up in advanced mode soon, and then roll it out for everything once we're sure it's not creating major new issues or complexity. But it made my mind hurt just thinking about all the possibilities it could open up (good and bad). So decided to make field-template context contain only known variables to start, and then jump into the rest after marinating a bit. :)

Share this post


Link to post
Share on other sites

Before adding any more features (:P) can someone have a test with thumbnails in repeater fields? I doesn't seem to work, as the opening page to make the thumbnails isn't showing any image (just empty) but the layout is there. Previously I even had at some point showing an error that the page can't resolve. I think I posted this issue already elsewhere but can't remember as I thought it was here. :)

Share this post


Link to post
Share on other sites

Haven't played with repeater yet, but will test this right after when I found time.

Share this post


Link to post
Share on other sites

Thanks apeisa, I'm currently again testing with repeaters and there seems an issue with cropimages (not sure if images suffer the same) when I add a new repeater element on page with an cropimage field and upload an image, after saving the page the added element dissapears. Though after adding an element again there's still the image uploaded before (already reported issue on repeater thread, but think not solved yet). But after saving the page again then, it stays there and when clicking the "thumbnail" link a new window opens with this error:

Fatal error: Call to a member function get() on a non-object in /Applications/XAMPP/xamppfiles/htdocs/pw-dev/site/modules/Thumbnails/ProcessCropImage/ProcessCropImage.module on line 50

Share this post


Link to post
Share on other sites

Thanks Soma. Can you post the link href that produces that error?

Share this post


Link to post
Share on other sites

Thanks. I understand the problem now. That link will turn into this selector later on:

$img = wire('pages')->get(1002)->images_repeater1122->get("p1000242.jpg");

Problem is, that the page 1002 doesn't have the field images_repeater1122, but the underlying repeater page has that. Not sure what would be the best fix, but it doesn't feel like very difficult to solve.

Share this post


Link to post
Share on other sites

PawelGIX: I merged your pull request. It works great.

Others: updating is little "nasty", since you need to put your thumb-config to the field settings. Not sure how this is best done in live site.

Share this post


Link to post
Share on other sites

I noticed when adding a new page with 15 images yesterday that it creates thumbnails for each crop config as soon as the page is saved. In my case I have 3 different crops so I ended up with 6mb of images for one page.

Shouldn't it be making thumbnails when requested by the templates on page view rather than trying to make all options for a page? This seems a bit wrong to me as some of the crops will only be used by one image in my case.

Also, does it do any tidying up after itself if you change a crop size in the config? I don't think it does, but I realise it might be hard to add this as well.

Share this post


Link to post
Share on other sites

It doesn't yet any cleaning up, even if you delete the images on page or even the field the images stay there. Only if you delete the page itself, they will get deleted.

Share this post


Link to post
Share on other sites

Hi! First of all, thank you for this wonderful module.

I am, however, experiencing some difficulties on using it properly. I experience the same issue some users reported back in the thread but while I've tried to apply the fix, it even got worse. So, here's what happening:

post-550-0-95596500-1337956047_thumb.png

Anyone has any clue on what may be going wrong?

Thank you!

Share this post


Link to post
Share on other sites

Have you created an image field and then set the inputfield (on field input settings tab) to "cropimage"? Or changed an already setup image field to use cropimage inputfield? If so, it won't work, you have to create a field using fieldtype "cropimage" from the start. I recently ran into this problem.

Share this post


Link to post
Share on other sites

Is there any way for this to be integrated with the TinyMCE image chooser? In other words an option in the image choosing screen to choose a 'thumbnail' instead of the main image and have all the thumbnail features in the page?

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 gebeer
      Although the PW backend is really intuitive, ever so often my clients need some assistance. Be it they are not so tech savvy or they are not working in the backend often.
      For those cases it is nice to make some help videos available to editors. This is what this module does.
      ProcessHelpVideos Module
      A Process module to display help videos for the ProcessWire CMS. It can be used to make help videos (screencasts) available to content editors.
      This module adds a 'Help Videos" section to the ProcessWire backend. The help videos are accessible through an automatically created page in the Admin page tree. You can add your help videos as pages in the page tree. The module adds a hidden page to the page tree that acts as parent page for the help video pages. All necessary fields and templates will be installed automatically. If there are already a CKEditor field and/or a file field for mp4 files installed in the system, the module will use those. Otherwise it will create the necessary fields. Also the necessary templates for the parent help videos page and it's children are created on module install. The module installs a permission process-helpvideos. Every user role that should have access to the help video section, needs this permission. I use the help video approach on quite a few production sites. It is stable so far and well received by site owners/editors. Up until now I installed required fields, templates and pages manually and then added the module. Now I added all this logic to the install method of the module and it should be ready to share.
      The module and further description on how to use it is available on github: https://github.com/gebeer/ProcessHelpVideos
      If you like to give it a try, I am happy to receive your comments/suggestions here.
    • By Robin S
      A module created in response to the topic here:
      Page List Select Multiple Quickly
      Modifies PageListSelectMultiple to allow you to select multiple pages without the tree closing every time you select a page.
      The screencast says it all:

       
      https://github.com/Toutouwai/PageListSelectMultipleQuickly
      https://modules.processwire.com/modules/page-list-select-multiple-quickly/
    • By gebeer
      Hello all,
      sharing my new module FieldtypeImagePicker. It provides a configurable input field for choosing any type of image from a predefined folder.
      The need for it came up because a client had a custom SVG icon set and I wanted the editors to be able to choose an icon in the page editor.
      It can also be used to offer a choice of images that are used site-wide without having to upload them to individual pages.
      There are no image manipulation methods like with the native PW image field.
      Module and full description can be found on github https://github.com/gebeer/FieldtypeImagePicker
      Kudos to @Martijn Geerts. I used his module FieldTypeSelectFile as a base to build upon.
      Here's how the input field looks like in the page editor:

      Hope it can be of use to someone.
      If you like to give it a try, I'm happy to hear your comments or suggestions for improvement. Eventually this will go in the module directory soon, too.
    • By bernhard
      @Sergio asked about the pdf creation process in the showcase thread about my 360° feedback/survey tool and so I went ahead and set my little pdf helper module to public.
      Description from PW Weekly:
       
      Modules Directory: https://modules.processwire.com/modules/rock-pdf/
      Download & Docs: https://github.com/BernhardBaumrock/RockPDF
       
      You can combine it easily with RockReplacer: 
      See also a little showcase of the RockPdf module in this thread:
       
    • By ukyo
      FieldtypeFontIconPicker
      Supported Icon Libraries
      FontAwesome 4.7.0 Uikit 3.0.34 IonicIcons 2.0.1 Cahangelog
      NOTE: Module store data without prefix, you need to add "prefix" when you want to show your icon on front-end, because some of front-end frameworks using font-awesome with different "prefix".
      Module will search site/modules/**/configs/IconPicker.*.php and site/templates/IconPicker.*.php paths for FieldtypeFontIconPicker config files.
      All config files need to return a PHP ARRAY like examples.
      Example config file : create your own icon set.
      File location is site/configs/IconPicker.example.php
      <?php namespace ProcessWire; /** * IconPicker : Custom Icons */ return [ "name" => "my-custom-icons", "title" => "My Custom Icon Set", "version" => "1.0.0", "styles" => array( wire("config")->urls->templates . "dist/css/my-custom-icons.css" ), "scripts" => array( wire("config")->urls->templates . "dist/js/my-custom-icons.js" ), "categorized" => true, "attributes" => array(), "icons" => array( "brand-icons" => array( "title" => "Brand Icons", "icons" => array( "google", "facebook", "twitter", "instagram" ) ), "flag-icons" => array( "title" => "Flag Icons", "icons" => array( "tr", "gb", "us", "it", "de", "nl", "fr" ) ) ) ]; Example config file : use existing and extend it.
      File location is site/configs/IconPicker.altivebir.php
      <?php namespace ProcessWire; /** * IconPicker : Existing & Extend */ $resource = include wire("config")->paths->siteModules . "FieldtypeFontIconPicker/configs/IconPicker.uikit.php"; $url = wire("config")->urls->templates . "dist"; $resource["scripts"] = array_merge($resource["scripts"], ["{$url}/js/Altivebir.Icon.min.js"]); $resource["icons"]["flag-icons"] = [ "title" => "Flag Icons", "icons" => array("tr", "en", "fr", "us", "it", "de") ]; $resource["icons"]["brand-icons"]["icons"] = array_merge($resource["icons"]["brand-icons"]["icons"], array( "altivebir" )); return $resource; After you add your custom config file, you will see your config file on library select box. Library Title (Location Folder Name).

      If your library categorized and if you have categorized icons set like uikit and fontawesome libraries, you will have category limitation options per icon field or leave it empty for allow all categories (default).

      Example : output
      if ($icon = $page->get("iconField")) { echo "<i class='prefix-{$icon}' />"; } MarkupFontIconPicker Usage
      // MarkupFontIconPicker::render(YourIconField=string, Options=array) echo MarkupFontIconPicker::render($page->YourIconField, [ 'prefix' => 'uk-icon-', // Icon class prefix, if you have different prefix, default is : "fa fa-" 'tag' => 'span', // Icon tag default is : "i" 'class' => 'fa-lg', // If you have extra cutom classes, for example : icons sizes, Array or Sting value 'style' => 'your custom styles if you have' // Array or String Value ]); Theme support

      Search support

      Category support

       
×
×
  • Create New...