cancel
Showing results for 
Search instead for 
Did you mean: 

magento 2 - dynamic images not showing in home page

magento 2 - dynamic images not showing in home page

after installing magento 2, dynamic images (Products/Slider/Blogs) are displaying in all website pages but not in home pages i cleared the cache, re-indexed the website and changes the media folder permission but none of them solve my problem

7 REPLIES

Re: magento 2 - dynamic images not showing in home page

Could you show your code for images where you have keep code for images? Also give a link for your site url?
If Issue Solved, Click Kudos/Accept As solutions.

Re: magento 2 - dynamic images not showing in home page

Here's my site url

http://abdessalam.com/lebanonFlower/

and i keep my images in media folder

Re: magento 2 - dynamic images not showing in home page

Hi @HalaAtef,

If you check the frontend there is image path but without image name like this. So, images are broken. It seems like images are not present in given path.

http://abdessalam.com/lebanonFlower/pub/media/catalog/product/resized/100x100/db4e66100f55e6657d33f65beabfc3e5/


Either images are not getting generated in the given path or they are removed from there.

Also, one more issue I see is there are no proper permissions set to your pub/media folder, I can see the directory listing in the browser which is not secure at all. If it is a production site, please take care of that ASAP and make sure that proper permissions are given to all the folder.

--------
Give Kudos if it helped or Accept it as a solution

 

Re: magento 2 - dynamic images not showing in home page

@kalyanchakrithank you for your reply

 

plz note that this it a demo server, also plz note that i was the one who delete the images but before deleting it the problem was exist

now i restore the images but the problem is still exist

 

i can not figure the reason of the problem

Re: magento 2 - dynamic images not showing in home page

Hi @HalaAtef,

Thanks for the clarification.

Can you please paste the code you are using to fetch the images?


--------
Give Kudos if it helped or Accept it as a solution

Re: magento 2 - dynamic images not showing in home page

here's my code:

 

<div class="list-items <?php echo $class_respl; ?> ">
            <?php  $j = 0;
            foreach ($list as $_product) { $j++;
                ?>
                <!-- Begin bs-item-cf -->
                <div class="item bs-item cf">
                    <!-- Begin bs-item-inner -->
                    <div class="item-inner">
                        <?php if ($_product->_image) { ?>
                            <div class="box-image">
                                <a href="<?php echo $_product->link ?>"
                                   title="<?php echo $_product->title; ?>"
                                    <?php echo $helper->parseTarget($this->_getConfig('target')); ?>
                                    >
                                    <img src="<?php echo $_product->_image; ?>"
                                         title="<?php echo $_product->title; ?>"
                                         alt="<?php echo $_product->title; ?>"
                                        >
                                </a>
                                
                                
                                
                                <div class="bottom-action">
                                    <?php if ((int)$this->_getConfig('product_addcart_display', 1)) { ?>
                                        <?php if ($_product->isSaleable()){ ?>
                                            <?php if ($_product->getTypeInstance()->hasRequiredOptions($_product)){ ?>
                                                <button class="action tocart btn-action btn-cart" data-mage-init='{"redirectUrl": {"url": "<?php echo $block->getAddToCartUrl($_product) ?>"}}' type="button" title="<?php  echo __('Add to Cart') ?>">
                                                    <span><?php  echo __('Add to Cart') ?></span>
                                                </button>
                                            <?php } else { ?>
                                                <?php $postDataHelper = $this->helper('Magento\Framework\Data\Helper\PostHelper');
                                                $postData = $postDataHelper->getPostData($block->getAddToCartUrl($_product), ['product' => $_product->getEntityId()])
                                                ?>
                                                <button class="action tocart btn-action btn-cart"
                                                        data-post='<?php echo $postData; ?>'
                                                        type="button" title="<?php  echo __('Add to Cart') ?>">
                                                    <span><?php echo __('Add to Cart') ?></span>
                                                </button>
                                            <?php } ?>
                                        <?php } else { ?>
                                            <?php if ($_product->getIsSalable()){ ?>
                                                <div class="stock available"><span><?php  echo __('In stock') ?></span></div>
                                            <?php } else { ?>
                                                <div class="stock unavailable"><span><?php  echo __('Out of stock') ?></span></div>
                                            <?php } ?>
                                        <?php } ?>
                                    <?php } ?>
                                    
                                    <?php if ((int)$this->_getConfig('product_addwishlist_display', 1) || (int)$this->_getConfig('product_addcompare_display', 1)) { ?>

                                            <?php if ($this->helper('Magento\Wishlist\Helper\Data')->isAllow() && (int)$this->_getConfig('product_addwishlist_display', 1) ){ ?>
                                                <a href="#" data-post='<?php  echo $block->getAddToWishlistParams($_product); ?>'  class="action towishlist btn-action link-wishlist" data-action="add-to-wishlist" title="<?php  echo __('Add to Wish List') ?>">
                                                    <span><?php  echo __('Add to Wish List') ?></span>
                                                </a>
                                            <?php } ?>
                                            
                                            <?php if ($block->getAddToCompareUrl() &&  (int)$this->_getConfig('product_addcompare_display', 1)){ ?>
                                                <?php
                                                $compareHelper = $this->helper('Magento\Catalog\Helper\Product\Compare');
                                                ?>
                                                <a href="#" class="action tocompare btn-action link-compare"
                                                   data-post='<?php  echo $compareHelper->getPostDataParams($_product);?>'
                                                   data-role="add-to-links"
                                                   title="<?php  echo __('Add to Compare'); ?>">
                                                    <span><?php  echo __('Add to Compare') ?></span>
                                                </a>
                                            <?php }; ?>
                                    <?php } ?>
                                    
                                </div>
                            </div>
                        <?php }?>

                        <!-- Begin bs-content -->
                        <?php  ?>
                        <div class="product details product-item-details box-info">

                            <?php if ((int)$this->_getConfig('product_title_display', 1)) { ?>
                                <h2 class="product name product-item-name product-name">
                                    <a href="<?php echo $_product->link; ?>" title="<?php echo $_product->title; ?>"
                                        <?php echo $helper->parseTarget($this->_getConfig('target')); ?>
                                        >
                                        <?php echo $helper->truncate($_product->title, $this->_getConfig('product_title_maxlength')); ?>
                                    </a>
                                </h2>
                            <?php } ?>
                            
                            <?php if ($this->_getConfig('product_source') != 'media') { ?>
                                <?php if ((int)$this->_getConfig('product_price_display', 1)) {
                                    echo $this->getProductPrice($_product);
                                } ?>
                                <?php if ((int)$this->_getConfig('product_reviews_count', 1)) {
                                        $templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface:Smiley FrustratedHORT_VIEW;
                                        echo $block->getReviewsSummaryHtml($_product,$templateType,true);
                                } ?>
                                
                            <?php } ?>
                            
                            <?php if ((int)$this->_getConfig('product_description_display', 1) && $helper->_trimEncode($_product->_description) != '') { ?>
                                <div class="bs-description">
                                    <?php echo $_product->_description; ?>
                                </div>
                            <?php } ?>
                            
                            <?php if ($this->_getConfig('cat_title_display') == 1 && $this->_getConfig('product_source') != 'media') { ?>
                               <div class="bs-category"><?php echo __('Category:&nbsp') ;?>
                                    <a  href="<?php echo $_product->cat_link; ?>"  title="<?php echo $_product->cat_title; ?>"  <?php echo $helper->parseTarget($this->_getConfig('target')); ?>>
                                         <?php echo  $helper->truncate($_product->cat_title, $this->_getConfig('category_title_max_characs', 25)); ?>
                                    </a>
                                    
                                </div>
                            <?php } ?>

                                
                            <?php if ($this->_getConfig('product_source') != 'media') { ?>

                                <?php if ((int)$this->_getConfig('product_addcart_display', 1) ||(int)$this->_getConfig('product_addwishlist_display', 1) || (int)$this->_getConfig('product_addcompare_display', 1)) { ?>
                                <div class="product actions product-item-actions">
                                    

                                    
                                </div>
                                <?php } ?>
                            <?php } ?>

                            <?php if ($this->_getConfig('product_readmore_display') == 1) { ?>
                                <div class="bs-detail">
                                    <a href="<?php echo $_product->link ?>"
                                       title="<?php echo $_product->title; ?>"
                                        <?php echo $helper->parseTarget($this->_getConfig('target')); ?>
                                        >
                                        <?php echo $this->_getConfig('product_readmore_text', 'Details'); ?>
                                    </a>
                                </div>
                            <?php } ?>
                            
                        </div>
                        
                        <!-- End bs-content -->
                    </div>
                    <!-- End bs-item-inner -->
                </div><!-- End bs-item-cf -->
                <?php
                $clear = 'clr1';
                if ($j % 2 == 0) $clear .= ' clr2';
                if ($j % 3 == 0) $clear .= ' clr3';
                if ($j % 4 == 0) $clear .= ' clr4';
                if ($j % 5 == 0) $clear .= ' clr5';
                if ($j % 6 == 0) $clear .= ' clr6';
                ?>
                <div class="<?php echo $clear; ?>"></div>
            <?php } ?>
        </div>

Re: magento 2 - dynamic images not showing in home page

Dears, i am still have the same issue, anyone can help plz