Jump to content

Image/Files Uploading


Gazley
 Share

Recommended Posts

Hi there,

In ExpressionEngine (EE), you can define target upload folders and specify what can be uploaded. For now, my main area of concern is images. In your templates, you can then specify the upload folder for image placement.

In EE, when you upload an image, you can also specify a list of additional named "actions" against the original upload that will, for example, create different versions of the images at different sizes. So, with a single image upload, you would have the original full size image, maybe a "thumbs" folder with a userdefined thumbnail size, and perhaps a "medium" folder with the image at 50% of its original size.

This is really flexible and I wondered whether there is anything like this in PW or how you would routinely achieve this kind of thing?

Many thanks.

Link to comment
Share on other sites

Unfortunately, you can't define any actions in ProcessWire.

You also can't define where the files go — they always upload into /site/assets/files/$page_id. Regarding different file sizes, those are generated automatically when you load resized versions via $page->image->size() [this pseudocode, real image call is a little different]

this is also to remeber, that if you e.g. Create gallery with 200+ images, first load takes a while, when different sizes are created., so it's better to do the first page load yourself, immediately

Link to comment
Share on other sites

Thanks for your reply. When you refer to /site/assets/files/$page_id - as this is all new to me at this stage, I assume then that $page_id represents and individual page entity and if so, then assets used by the page are stored with the page? The downside being that they [assets] cannot be accessed from other pages. Is this correct?

If there is anything in the documentation that is definitive around this topic, that would also help.

Thanks again :)

Link to comment
Share on other sites

Sorry, I assumed you had your first look around :)

Yes, pictures are stored with the page, and are specific to page; In most use cases, this is fine.

If you need to reuse images, there are always ways how to achieve it, easily, but there are many ways, based on scenario. As PW happens to be different sort of beast than most CMS, this often actually isn't needed... Well you'll find this out soon enough ;)

Some documentation regarding images is here: http://processwire.com/api/fieldtypes/images/

Link to comment
Share on other sites

For different sized images the way I think you want to use them, check out the Thumbnails module in the modules directory. It's easy to set up and you can set per-template thumbnail sizes, as well as crop the larger image based off those sizes via the page editor.

You're right in your interpretation of how the files are stored for each page in their own folder per page. This isn't a limitation though the more you learn ProcessWire. You can include images from other pages by inserting them through TinyMCE from other pages, and of you really want to you can easily create a page called "Media" for example and subpages for each category and store your images in those in the fashion you would with folders in other CMS' - it's much more flexible this way.

For examples, let's say you create a hidden page called 'media,' and subpages called News, Blog and General, all using a template called 'mediagallery'. The template could just have a title and images field. You can then store images under those pages and include them via TinyMCE and you've got that familiar structure already.

The beauty though is that you can do other things. Pretend you weren't trying to use it as a file manager but an actual image gallery and in your template for the paret media page you could list all categories by doing something like:

foreach ($pages->get('/media/')->children() as $gallery) {
   echo "<p><a href='{$gallery->url}'>{$gallery->title}</a></p>";
}

And then for your gallery page you could list the images using something similar like foreach ($page->images as $image) {

and so on.

I'm willing to wager though that as soon as you start using ProcessWire that you probably won't want an old-fashioned media manager. How many times are images really re-used across websites? I've built a 500 page site where they haven't been re-used at all, and several smaller sites where the same is true.

I'm not saying that a media manager wouldn't be useful to you, just that there is almost always a different, often more useful way of doing things in ProcessWire, so if you could list some examples of where you would need to re-use images we could offer some suggestions.

I didn't mean any of that to sound big-headed by the way, just trying to offer helpful suggestions as I know first-hand it can take time to wrap your head around this different way of doing things and un-learn other systems.

(Apologies if there are any humorous errors in my post above as I'm typing this all on an iPhone that almost left me typing "wrap your wad" in that last sentence).

Link to comment
Share on other sites

Thanks Pete! I will study yours and adamkiss's suggestions. I'm really impressed that there is any kind of response over the weekend. BTW, I'm based in Manchester so, not a million miles away from you! If it's OK with you, I'll get back to you if I need a little more advice.

Regards! :)

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
 Share

×
×
  • Create New...