[Skip to main content](#vessel-content)

#   Insert a Custom Field Image

##

- **[Jovian](/forum/user/31238-jovian "View Jovian's Profile")**
- [![Jovian's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/31238-jovian "View Jovian's Profile") Topic Author
- [ Offline](/forum/user/31238-jovian)

Less More

- Posts: 41
- Thank you received: 0
-
-

10 years 6 months ago [\#237368](#237368) by [Jovian](/forum/user/31238-jovian "View Jovian's Profile")  *[Insert a Custom Field Image](/forum/31-development/883977-insert-a-custom-field-image#237368 "-- url of the page with the problem -- :   www.mybodygraph.com  -- HikaShop version -- : 2.6.2 -- Joomla version -- : 3.4.8 -- PHP version -- : 5.5.33  I'm trying to get a image from a Ajax Image custom field. I did't find any documentation on this so I copied the code from show&#95;block&#95;img but I don't get it to work.  the file I'm working in is product/show&#95;default.php, the image that gets displayed is from something totally different and it simply seem to ignore the path and filename, can you guys guide me how to do this in a correct way? Here is the code I'm using right now:")* was created by *[Jovian](/forum/user/31238-jovian "View Jovian's Profile")*

-- url of the page with the problem -- : [ www.mybodygraph.com](http://www.mybodygraph.com)
-- HikaShop version -- : 2.6.2
-- Joomla version -- : 3.4.8
-- PHP version -- : 5.5.33

I'm trying to get a image from a Ajax Image custom field. I did't find any documentation on this so I copied the code from show_block_img but I don't get it to work.

the file I'm working in is product/show_default.php, the image that gets displayed is from something totally different and it simply seem to ignore the path and filename, can you guys guide me how to do this in a correct way? Here is the code I'm using right now:
Code:

$variant_name = ''; $variant_main = '_main'; $height = (int)$this-&gt;config-&gt;get('product_image_y'); $width = (int)$this-&gt;config-&gt;get('product_image_x'); echo $this-&gt;image-&gt;display('/media/com_hikashop/upload/safe/', true, $this-&gt;element-&gt;product_display,'id="hikashop_main_image'.$variant_name.'" style="margin-top:10px;margin-bottom:10px;display:inline-block;vertical-align:middle"','id="hikashop_main_image_link"', $width, $height);

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg4Mzk3Ny1pbnNlcnQtYS1jdXN0b20tZmllbGQtaW1hZ2U/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86541
- Thank you received: 14304
-
-

10 years 6 months ago [\#237378](#237378) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Insert a Custom Field Image](/forum/31-development/883977-insert-a-custom-field-image#237378 "-- url of the page with the problem -- :   www.mybodygraph.com  -- HikaShop version -- : 2.6.2 -- Joomla version -- : 3.4.8 -- PHP version -- : 5.5.33  I'm trying to get a image from a Ajax Image custom field. I did't find any documentation on this so I copied the code from show&#95;block&#95;img but I don't get it to work.  the file I'm working in is product/show&#95;default.php, the image that gets displayed is from something totally different and it simply seem to ignore the path and filename, can you guys guide me how to do this in a correct way? Here is the code I'm using right now:")*

Hi,

That's not how you should do it at all.
You should load the custom field settings and then use the custom field class to display the field value. So supposing that it is a custom field of the table "product": Code:

$fieldClass = hikashop_get('class.field'); $field = $fieldClass-&gt;getField('product_display', 'product'); echo $fieldClass-&gt;show($field,$this-&gt;element-&gt;product_display);

The following user(s) said Thank You: [Jovian](/forum/user/31238-jovian "View Jovian's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg4Mzk3Ny1pbnNlcnQtYS1jdXN0b20tZmllbGQtaW1hZ2U/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jovian](/forum/user/31238-jovian "View Jovian's Profile")**
- [![Jovian's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/31238-jovian "View Jovian's Profile") Topic Author
- [ Offline](/forum/user/31238-jovian)

Less More

- Posts: 41
- Thank you received: 0
-
-

10 years 6 months ago [\#237535](#237535) by [Jovian](/forum/user/31238-jovian "View Jovian's Profile")  Replied by *[Jovian](/forum/user/31238-jovian "View Jovian's Profile")* on topic *[Insert a Custom Field Image](/forum/31-development/883977-insert-a-custom-field-image#237535 "-- url of the page with the problem -- :   www.mybodygraph.com  -- HikaShop version -- : 2.6.2 -- Joomla version -- : 3.4.8 -- PHP version -- : 5.5.33  I'm trying to get a image from a Ajax Image custom field. I did't find any documentation on this so I copied the code from show&#95;block&#95;img but I don't get it to work.  the file I'm working in is product/show&#95;default.php, the image that gets displayed is from something totally different and it simply seem to ignore the path and filename, can you guys guide me how to do this in a correct way? Here is the code I'm using right now:")*

Thank you, that returns a thumbnail of the image! But we also need to set the size of the image in the PHP ourself depending on this and that, how can we do that?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg4Mzk3Ny1pbnNlcnQtYS1jdXN0b20tZmllbGQtaW1hZ2U/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86541
- Thank you received: 14304
-
-

10 years 6 months ago [\#237541](#237541) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Insert a Custom Field Image](/forum/31-development/883977-insert-a-custom-field-image#237541 "-- url of the page with the problem -- :   www.mybodygraph.com  -- HikaShop version -- : 2.6.2 -- Joomla version -- : 3.4.8 -- PHP version -- : 5.5.33  I'm trying to get a image from a Ajax Image custom field. I did't find any documentation on this so I copied the code from show&#95;block&#95;img but I don't get it to work.  the file I'm working in is product/show&#95;default.php, the image that gets displayed is from something totally different and it simply seem to ignore the path and filename, can you guys guide me how to do this in a correct way? Here is the code I'm using right now:")*

Hi,

In that case, you can do like that: Code:

$fieldClass = hikashop_get('class.field'); $field = $fieldClass-&gt;getField('product_display', 'product'); echo str_replace(array('thumbnail_x=100','thumbnail_y=100'),array('thumbnail_x='.$width,'thumbnail_y='.$height),$fieldClass-&gt;show($field,$this-&gt;element-&gt;product_display));

The following user(s) said Thank You: [Jovian](/forum/user/31238-jovian "View Jovian's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg4Mzk3Ny1pbnNlcnQtYS1jdXN0b20tZmllbGQtaW1hZ2U/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.047 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
