Jump to content

Release: Thumbnails


apeisa

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?

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

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

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

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

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

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

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

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

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

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

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

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

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

Link to comment
Share on other sites

  • 2 months later...

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!

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

Link to comment
Share on other sites

  • 2 weeks later...

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?

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