Jump to content

how to integrate a simple image?


ashrai
 Share

Recommended Posts

hey there,

sorry for dumb questions ... but I am a total boon concerning php and cms developement. Just had some minor contact with contao and wordpress. Now I decided to learn how to use a cms and got stuck with processwire. I love the general idea of it. =)

So ... I followed the "getting started" tutorial and I was impressed how fast my first editable text areas emerged "out of nowhere". ;)

Now I tried to place an editable/changeable image.

And I have no clue how to do this. If I search this forum all I find are advanced solutions for sorting images and so on.

Help. Sorry again - I'm at the very beginning. :)

Link to comment
Share on other sites

Hi ashrai! Welcome to the forums!

There is a tutorial about adding images here http://processwire.c...k-start/images/ (it's admittedly a bit hidden because it's considered "in progress")

Make sure you understand the difference between single images fields (Maximum files allowed = 1, in the field options), and multiple images fields. On the first one $page->field returns an object, and on the former it returns an array.

On the single image you return the url simply like this:

echo $page->image_field->url;

And on the multiple, you return the several urls like this:

foreach($page->images_field as $image){
   echo $image->url . "<br>"; // this will print one url per line
}

Well, all this is explained in that tutorial I linked to.

  • Like 2
Link to comment
Share on other sites

Hi diogo,

this explains why I haven't found it!

Thank you! I'll try this at once. :)

//edit:

Yes, that worked! Many thanks! :)

I understood the syntax, too, I think.

My only problem ist: Why do I need the "Class=Photo" Attribute as shown in the tutorial code? What does it do?

I create an Instance of $image and I thought that this already is the php class I need to display/resize/etc. ... my image. Did I get something wrong?

Link to comment
Share on other sites

You don't need it. This is there only for the example, you can use any class or id that you want or you don't have to use anything at all. The HTML part is completely up to you.

  • Like 1
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...