0

I decided to use intro image in article instead of j2store thumbnail image

use below code But did not show image

<?php echo json_decode($item->images)->image_intro; ?>
or
<?php echo json_decode($item->images)->image_fulltext; ?>

code at default_image.php j2store module

    <?php
/**
* @package J2Store
* @copyright Copyright (c)2016-19 Sasi varna kumar / J2Store.org
* @license GNU GPL v3 or later
*/
defined('_JEXEC') or die;
$image_root_path = JUri::root();
$image_path = '' ;
if ($product->image_type == 'thumbimage' && isset($product->thumb_image) ) {
    $image_path = $product->thumb_image ; 
} else if ($product->image_type == 'mainimage' && isset($product->main_image) ) {
    $image_path = $product->main_image ; 
}
if($product->image_position == 'top'){
    $img_class = 'col-md-12 ';
}else {
    $img_class = 'col-md-6 ';
}
?>
<?php if($product->show_image): ?>
<div class="j2store-product-image  <?php echo $img_class; ?> ">
    <?php if(JFile::exists(JPATH_SITE.'/'.JPath::clean($image_path))):?>
        <?php if($product->module_display_link && $product->link_image ): ?>
            <a href="<?php echo $product->module_display_link; ?>" title="<?php echo $product->product_name; ?>">
        <?php endif;?>
        <img itemprop="image" alt="<?php echo $product->product_name ;?>" 
        class="j2store-img-responsive j2store-product-image-<?php echo $product->j2store_product_id; ?>"  
        src="<?php echo $image_root_path.$image_path;?>" 
        width="<?php echo $product->image_size_width ;?>" 
        height="<?php echo $product->image_size_height ;?>"  />

        <?php if($product->module_display_link): ?>
            </a>
        <?php endif;?>
    <?php endif; ?>
</div>
<?php endif; ?>
  • After your question got clearer for me, I updated my answer on this for you. – Zollie Jan 16 at 15:30
0

Your question is quite unclear, however I try to help you if I can with the following:

After two hours, I started to understand what your question means. :) That you want to use the Jooomla article intro image as the product main image. Now I got that. It’s confusing first since J2Store has it’s own pretty good image handling part. The developer deliberately developed their own image handling in J2Store in the new version (J2Store 3).

So if you go to Content - J2Store plugin and set the option display image in list view or in item view to no, then J2store will use the article intro image of the article automatically. You do not have to use any coding for that.

More info on this here: https://www.j2store.org/component/kunena/2-general-questions/3804-use-first-image-of-article-for-product-thumbnail.html?start=6

UPDATE - HOW TO USE THE ARTICLE INTRO IMAGE IN PRODUCT DISPLAY MODULE

So as in the comment it got finally clear that the question was about the J2Store Product display module and now I have a little time to check and test this, here is how you can get and use the article intro image as main image in that module and use that in the display:

You have to just insert these line on the top of the module default_image.php file which you give above (insert it after defined('_JEXEC') or die; line):

// to have article intro_image
$search_id = $product->product_source_id;
$article = JTable::getInstance('Content', 'JTable');
$article->load($search_id);    

$article_raw = json_decode($article->images, false);
$article_intro_image_src = "/". $article_raw->image_intro;

$product->main_image = $article_intro_image_src;

What these few lines do is getting the product source ID which is actually the Joomla article id too and then get the article intro image path from the database (via using JTable). And then defines the main product image as article intro image.

Thus, if you set in the module settings the option to show main images then the module will display the article intro images.

Now, I hope it fully answered what you were looking for. :) (cheers)

  • This is the solution for the articles inside But I want to display the product module – niaziblog Jan 16 at 19:48
  • @niaziblog - Ohh, you want to display the article intro image in the product module. Now I understand it better. – Zollie Jan 16 at 20:09
  • @niaziblog - Just a bit better... Where do you want to display the module? Would it be a normal Joomla module with few product' info in it or how would it look like? Maybe an image about what exactly you would want to see, could explain your need and purpose even better. That's the only way to have anybody help you. $item->images and so on are not defined globally, so that way you cannot just access these variables anywhere within Joomla. – Zollie Jan 16 at 20:29
  • Module link : j2store.org/extensions/modules/product-display-module.html .... i want show joomla article image instead of j2store thumb image at this module – niaziblog Jan 16 at 22:34
  • @niaziblog - now it’s fully clear what you want to achieve. :) Thanks! – Zollie Jan 17 at 3:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.