Keyword

K2 Extra Field Image

  • andrea
  • andrea's Avatar Topic Author
  • Offline
  • Junior Member
More
11 years 8 months ago #108814 by andrea
K2 Extra Field Image was created by andrea
hi guys, i have 1 extra field type IMAGE.

I would like that when a user insert the image, in the frontend show the image + fancybox effect.

My problem is give the only path of image.. I try with:
Log in  or Create an account to join the conversation.

More
11 years 8 months ago #108815 by william white
Replied by william white on topic Re: K2 Extra Field Image
Just a guess
Look in phpmyadmin and edit an item that has an image for xtra field
determine that only the filename is stored there.
Find the path to the filename
change your code to
<code>
<a class="galleria" data-fancybox-group="gallery" title="<?php K2HelperUtilities::cleanHtml($item->title); ?>" href="<?php echo "PATHNECESSARYTOFINDFILE" . $this->item->extraFields->Image->value; ?>" > <?php echo $custom[5]->value; ?></a>

Please Log in or Create an account to join the conversation.

  • andrea
  • andrea's Avatar Topic Author
  • Offline
  • Junior Member
More
11 years 8 months ago #108816 by andrea
Replied by andrea on topic Re: K2 Extra Field Image
Hi William thank you for your answer.

I just see in the table "k2_items" and in the field "extra_fields" this:
Log in  or Create an account to join the conversation.

More
11 years 8 months ago #108817 by william white
Replied by william white on topic Re: K2 Extra Field Image
what version of k2 are you using?

Please Log in or Create an account to join the conversation.

  • andrea
  • andrea's Avatar Topic Author
  • Offline
  • Junior Member
More
11 years 8 months ago #108818 by andrea
Replied by andrea on topic Re: K2 Extra Field Image
2.6.2

Please Log in or Create an account to join the conversation.

More
11 years 8 months ago #108819 by william white
Replied by william white on topic Re: K2 Extra Field Image
is Image the xtrafield alias ?
from blog post 2.6.2
So how would you directly output individual extra fields in your K2 overrides? Simple. Just do something like this (e.g. in item.php) to get the extra field name:
$this->item->extraFields->EXTRAFIELDALIASHERE->name

To get the extra field value you would simply do this:
$this->item->extraFields->EXTRAFIELDALIASHERE->value

Simply replace EXTRAFIELDALIASHERE with the actual alias of the extra field you wish to output.

Please Log in or Create an account to join the conversation.

  • andrea
  • andrea's Avatar Topic Author
  • Offline
  • Junior Member
More
11 years 8 months ago - 11 years 8 months ago #108820 by andrea
Replied by andrea on topic Re: K2 Extra Field Image
i did it but don't works. I try with ->name and ->value but nothing.. in the href there is the value "Image 1" so the link is www.website.it/Image%201 .

Below the code:
Log in  or Create an account to join the conversation.

More
11 years 8 months ago #108821 by BBC
Replied by BBC on topic Re: K2 Extra Field Image
If Admin/User has permision to put PHP code in editor window is it possible to call image field in the middle of Item text / body?

Please Log in or Create an account to join the conversation.

More
11 years 8 months ago #108822 by william white
Replied by william white on topic Re: K2 Extra Field Image
Yes, or you can use somethin like Sourcerer from nonumber.nl

Please Log in or Create an account to join the conversation.

More
11 years 8 months ago - 11 years 8 months ago #108823 by william white
Replied by william white on topic Re: K2 Extra Field Image
@andrea
You can use this, or something similar to it to do what you need
<div>
<?php
$var = $this->item->extraFields->Image->value ;
$var = preg_replace('/<img src="/',"",$var);
$var = preg_replace('/" alt="Image" \>/'," ",$var);
echo '<a class="galleria" href="' . $var . "TextOfLink" ."</a>" ;
?>
</div>

Please Log in or Create an account to join the conversation.