- Posts: 4
COMMUNITY FORUM
Make Extra Field Images Popup in Modal Box
- Sarah
-
Topic Author
- Offline
- New Member
Less
More
7 years 11 months ago #162238
by Sarah
Make Extra Field Images Popup in Modal Box was created by Sarah
I have setup 12 Extra Field images. I want the client to be able to upload 12 images that display as thumbnails and then when clicked they pop open in a modal box.
This is the code I have and it does not open the Extra Field but instead another image on the page. I can't figure out why.
<a data-k2-modal="image" href="<?php echo $this->item->imageLarge; ?>" title="<?php echo JText::_('K2_CLICK_TO_PREVIEW_IMAGE'); ?>">
<?php echo $extrafields[1];?>
</a>
Can you please take a look at this code and let me know if there's a better way of doing this or at least a solution that will pop open the image from the extra field ID?
This is the code I have and it does not open the Extra Field but instead another image on the page. I can't figure out why.
<a data-k2-modal="image" href="<?php echo $this->item->imageLarge; ?>" title="<?php echo JText::_('K2_CLICK_TO_PREVIEW_IMAGE'); ?>">
<?php echo $extrafields[1];?>
</a>
Can you please take a look at this code and let me know if there's a better way of doing this or at least a solution that will pop open the image from the extra field ID?
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
7 years 11 months ago #162250
by Krikor Boghossian
Replied by Krikor Boghossian on topic Make Extra Field Images Popup in Modal Box
Hello Sarah
In each href attribute you need to echo the actual image's source instead of the $this->item->imageLarge code which links it to the item's main image.
href="<?php echo $this->item->imageLarge; ?>"
Please Log in or Create an account to join the conversation.
- Sarah
-
Topic Author
- Offline
- New Member
Less
More
- Posts: 4
7 years 11 months ago #162276
by Sarah
Replied by Sarah on topic Make Extra Field Images Popup in Modal Box
Thanks for helping narrow down my issue.
I've tried the extra field alias and ID number but both don't load. It says "The image could not be loaded."
Do you know how to echo the source of the extra field?
href="<?php echo $this->item->GalleryImageOne; ?>"
or
href="<?php echo $extrafields[1];?>"
I've tried the extra field alias and ID number but both don't load. It says "The image could not be loaded."
Do you know how to echo the source of the extra field?
href="<?php echo $this->item->GalleryImageOne; ?>"
or
href="<?php echo $extrafields[1];?>"
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
7 years 11 months ago #162281
by Krikor Boghossian
Replied by Krikor Boghossian on topic Make Extra Field Images Popup in Modal Box
The image field will render the entire <img> tag
This will help you:
getk2.org/documentation/tips-a-tricks/1129-extra-field-image-type-as-link
This will help you:
getk2.org/documentation/tips-a-tricks/1129-extra-field-image-type-as-link
Please Log in or Create an account to join the conversation.
- Joe Campbell
-
- Offline
- Platinum Member
Less
More
- Posts: 438
7 years 11 months ago #162291
by Joe Campbell
Replied by Joe Campbell on topic Make Extra Field Images Popup in Modal Box
Hi Sarah,
This post might help:
www.joomlaworks.net/forum/k2-en/40376-solved-keeping-orginal-names-in-my-images?limitstart=0#141480
Take Care,
Joe
This post might help:
www.joomlaworks.net/forum/k2-en/40376-solved-keeping-orginal-names-in-my-images?limitstart=0#141480
Take Care,
Joe
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
7 years 11 months ago #162298
by Krikor Boghossian
Replied by Krikor Boghossian on topic Make Extra Field Images Popup in Modal Box
This might sound a bit cliche' but thanks Joe :D
Please Log in or Create an account to join the conversation.
- Joe Campbell
-
- Offline
- Platinum Member
Less
More
- Posts: 438
7 years 11 months ago #162299
by Joe Campbell
Replied by Joe Campbell on topic Make Extra Field Images Popup in Modal Box
@Krikor - I am always glad to help a fellow K2er :)
Please Log in or Create an account to join the conversation.
- Sarah
-
Topic Author
- Offline
- New Member
Less
More
- Posts: 4
7 years 11 months ago - 7 years 11 months ago #162331
by Sarah
Replied by Sarah on topic Make Extra Field Images Popup in Modal Box
Thank you both for your help although I did not achieve what I'm trying to do from these links. It's very possible I'm not understanding it completely.
I tried this solution:
file: /components/com_k2/models/item.php
replace...
$value = '<img src="'.$src.'" alt="'.$rows[$i]->name.'" />';
with...
$value = $src; // K2 HACK - removed image markup
But it broke all of the thumbnails on my page. I want the extra field images to display and have them pop up in a modal box at a larger size.
Here is the page I'm trying to get working.
Part of the message is hidden for the guests. Please log in or register to see it.
Clicking on the thumbnails under the main image should pop open to display a larger image. Currently it says "The image could not be loaded."
I tried this solution:
file: /components/com_k2/models/item.php
replace...
$value = '<img src="'.$src.'" alt="'.$rows[$i]->name.'" />';
with...
$value = $src; // K2 HACK - removed image markup
But it broke all of the thumbnails on my page. I want the extra field images to display and have them pop up in a modal box at a larger size.
Here is the page I'm trying to get working.
Part of the message is hidden for the guests. Please log in or register to see it.
Clicking on the thumbnails under the main image should pop open to display a larger image. Currently it says "The image could not be loaded."
Last edit: 7 years 11 months ago by Sarah.
Please Log in or Create an account to join the conversation.
- Joe Campbell
-
- Offline
- Platinum Member
Less
More
- Posts: 438
7 years 11 months ago #162332
by Joe Campbell
Replied by Joe Campbell on topic Make Extra Field Images Popup in Modal Box
You can also use Regular Labs Articles Anywhere (Pro) to render K2 extra fields:
www.regularlabs.com/extensions/articlesanywhere#k2-extra-fields
www.regularlabs.com/extensions/articlesanywhere#k2-extra-fields
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
7 years 11 months ago #162344
by Krikor Boghossian
Replied by Krikor Boghossian on topic Make Extra Field Images Popup in Modal Box
That is indeed a killer funcionality, although some manipulation might be needed, since the <img> tag will be returned.
Please Log in or Create an account to join the conversation.