#1 2013-06-13 01:18:16

yasirb
Member
From: Norway
Registered: 2013-06-13
Posts: 6

Can Content Element has image field?

I have a content element named Employee and its fields are as Name, Designation, Email, Phone and image.
But there is no option to link the image with it. Can any one help me how to resolve image issue?

Offline

#2 2013-06-13 02:01:38

damascus
Member
From: Brisbane, Australia
Registered: 2013-04-08
Posts: 270
Website

Re: Can Content Element has image field?

Note - For 9.9.5, may be the same in 1.0 but cannot say for sure smile


PHP Conditionals

Whilst this is not necessarily the most efficient result (due to some slight increased db load), I personally created an 'extended field' for Media - titled 'internal-id' - then did a check against all linked media for that internal id, ie:

your_view_file.php

<ion:items>
...
<ion:article:medias type="picture">
  <?php $_this_image_id = "<ion:image-internal-id:value />"; // content element field ?>
  <ion:article:medias type="picture">
  <?php if( $_this_image_id == "<ion:media:get key='ion_internal-id' />") { ?>
    <ion:media>
      <img src="<ion:media:src />" alt="<ion:alt />" />
    </ion:media>
  <?php } ?>
</ion:article:medias>

Its a simple enough solution, though there is some increased load time as your still printed ALL linked media.

A better approach would be making use of <ion:if /> and expressions, as this would limit the parsers workload, especially for large numbers of images.

For Example
Create a Media extended field (title extfield in this case) and then use the following:

<ion:page:medias>
  <ion:media expression="ion_extfield = 'my_extfield_value'">
    found 
  </ion:media>
</ion:page:medias>

The only question is using php variables in there, which (so far as I know) cannot be used.

This is something I really think should be more clearly documented, I've already contributed to more than one post regarding this but for dealing with this situation, I've only found inline php conditionals (as in the first example) to be reliable.

So it really depends on how many media items there are and whether your willing to sacrifice a little efficiency for simplicity, though tag caching should reduce the strain.


Or With Custom Tags

An alternative is a custom tag, not unlike what I discussed in http://www.ionizecms.com/forum/viewtopic.php?id=1243.

Though you would probably have to be a little tricky, you may be able to create a custom tag which takes each element of the article/page (context) and also checks through linked media for the extended fields value.

Though you would still be querying the db/stack for all media items so you may need to minimize the number of data requests, this would be simpler on the front-end and most likely be a gain in terms of processing power/time wink 


If I have a need for that myself (too few images so far) then I'll check it out myself, but as it is I know its possible and would love if anyone could try it out - this would be a useful tag.


regards,
Damascus

Last edited by damascus (2013-06-13 02:06:13)


Webmaster | OneCNC Australia

Offline

#3 2013-06-13 07:49:17

Larsen
Member
From: Switzerland
Registered: 2013-05-21
Posts: 13

Re: Can Content Element has image field?

Hi yasirb,

i solved this differently and without any php or whatsoever.

I just created a field called image with type text input. When creating your employee you have to put the filename in there and call it inside the view like so:

<img src="www.example.com/files/images/<ion:image:value/>" alt="<ion:name:value />" title="<ion:title />" width="100px" />

Did a similar thing for PDF files in a product overview.

regards, Larsen

Offline

#4 2013-06-13 09:36:53

damascus
Member
From: Brisbane, Australia
Registered: 2013-04-08
Posts: 270
Website

Re: Can Content Element has image field?

Larsen wrote:

Hi yasirb,

i solved this differently and without any php or whatsoever.

I just created a field called image with type text input. When creating your employee you have to put the filename in there and call it inside the view like so:

<img src="www.example.com/files/images/<ion:image:value/>" alt="<ion:name:value />" title="<ion:title />" width="100px" />

Did a similar thing for PDF files in a product overview.

regards, Larsen


err...

really doesnt seem efficient, impossible for me as im deploying to multiple hosts.

If you must do it that way then at least use

base_url()."files/";

That should allow you to not need to hardcode file-paths / url's in your view, which is really ill-advised.


Hope it helps,
Damascus


Webmaster | OneCNC Australia

Offline

#5 2013-06-13 11:24:54

GWR
Member
Registered: 2013-02-25
Posts: 125

Re: Can Content Element has image field?

As he has given "www.example.com" I think he already used a relative/dynamic-url-approach (so ../ or base_url()-calls).

Instead of having people to insert file names to input fields, one should have hidden fields (for file names) and another window which opens on "select picture". This window has some user selectable images, clicking on one selects it, pressing the "select"-button, sets the hidden field to the correct value.

Why? Just avoid forcing editors to write filenames correctly. Also you could easily adjust it to use media-ids which is more flexible.

Instead of calling an image by it's path you then just add a custom tag which calls your own "media library" which handles the call to media ids (eg. it does media resizing, watermarking ...) - or it routes the call to the cms-own-media-library.

There are many options (which include much work to do - but keep the whole thing dynamically adjustable).

bye
Ron

PS: if using an input field. Please!! validate and XSS-clean and secure the input (else an ../../../XYZ can do wonders)

Last edited by GWR (2013-06-13 11:26:38)

Offline

#6 2013-06-13 15:49:16

Larsen
Member
From: Switzerland
Registered: 2013-05-21
Posts: 13

Re: Can Content Element has image field?

That would definitely be a feature I'm looking forward to.

And yes, my solution is not fail safe or fool proof, just trying to get along with the tools and facilities I'm given.

Offline

#7 2013-06-13 20:58:17

yasirb
Member
From: Norway
Registered: 2013-06-13
Posts: 6

Re: Can Content Element has image field?

Thanks all of you!

you gave me some ideas which i may use for time being.

Yes! There should be solution or way in Ionize to tackle these things.

Offline

#8 2013-06-13 22:19:12

Michel-Ange
Ionize Core Team
From: Paris, France
Registered: 2010-03-22
Posts: 927
Website

Re: Can Content Element has image field?

The best solution is that we add "native media" type to content element and extend fields.
So adding one media to one content element or through one extend will be as simple as add one image to one article...

We will implement it.


Inspiration & Innovation : Websites by Partikule, Agence Web Paris

Offline

#9 2013-06-13 22:37:06

yasirb
Member
From: Norway
Registered: 2013-06-13
Posts: 6

Re: Can Content Element has image field?

Yes, you are right new "media picker" and "upload" type should be added in both content element and extend field.

Hopefully we will see these implementation soon!

Offline

#10 2013-06-14 00:27:07

Michel-Ange
Ionize Core Team
From: Paris, France
Registered: 2010-03-22
Posts: 927
Website

Re: Can Content Element has image field?

Media picker : yes.
Upload : OK, but where will be stored the file if you speak about frontend available upload ? In the "file" folder ? I'm open to suggestions...


Inspiration & Innovation : Websites by Partikule, Agence Web Paris

Offline

#11 2013-06-14 09:00:19

GWR
Member
Registered: 2013-02-25
Posts: 125

Re: Can Content Element has image field?

frontend uploads always should go into a "publicupload" or "userupload" folder (exception is if you review each file first ... then they should go into "pending").

Also make sure that that folder is correctly chmod'ed to avoid security issues.

@Media picker: that media picker should be able to get configured before opening (so you can specify certain folders - eg. with the employee pictures).


bye
Ron

Offline

#12 2013-06-14 10:50:11

yasirb
Member
From: Norway
Registered: 2013-06-13
Posts: 6

Re: Can Content Element has image field?

@Ionize Core Team! No i am not talking about frontend upload while i was saying the upload property/field will be available in Content element and Extend field.

I think that files uploaded though Media manger, same file could be link to many articles/pages. while file uploaded via upload field should only be link to those articles/pages where file upload field is used.

Yasir

Offline

#13 2013-10-16 10:08:55

salgua
Member
From: Italy
Registered: 2013-04-11
Posts: 60

Re: Can Content Element has image field?

Michel-Ange wrote:

The best solution is that we add "native media" type to content element and extend fields.
So adding one media to one content element or through one extend will be as simple as add one image to one article...
We will implement it.

Hi Michel! Any news about this feature? When do you plan to release it?
Thank you very much!

Last edited by salgua (2013-10-16 10:09:58)

Offline

#14 2014-01-25 11:04:46

Michel-Ange
Ionize Core Team
From: Paris, France
Registered: 2010-03-22
Posts: 927
Website

Re: Can Content Element has image field?

@salgua : it is planned, yes !


Inspiration & Innovation : Websites by Partikule, Agence Web Paris

Offline

#15 2014-07-02 05:52:04

damascus
Member
From: Brisbane, Australia
Registered: 2013-04-08
Posts: 270
Website

Re: Can Content Element has image field?

@toopixel
@moderators

Can we please move this to proper category?


Webmaster | OneCNC Australia

Offline

What's Ionize ?

Ionize is an Open Source Content Management System created by webdesigners for webdesigners.

Created and maintained by Partikule and Toopixel, Ionize wants to be the easiest and most powerful CMS.

Can I help ?

Because talent is nothing without involvement, we are looking for motivated coders and webdesigners to join the project team.

Resources

Website : ionizecms.com
Documentation : doc.ionizecms.com

Development : Ionize on GitHub
Translations : Ionize Translations