cancel
Showing results for 
Search instead for 
Did you mean: 

Images not showing in wysiwyg frontend page

Images not showing in wysiwyg frontend page

Hi,

 

I have placed an image in the description via the WYSIWYG editor in admin backend.

 

If I check the page in frontend while I am logged in into the admin page - the images display fine, but when I logout, it will display as a broken image link.

 

does anyone know how can I fix this?

 

thanks

5 REPLIES 5

Re: Images not showing in wysiwyg frontend page

@robertbits,

 

have you got directly using image path? Its not working for you. You need to get content from page object and display your content. can you share your full file code?

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

Re: Images not showing in wysiwyg frontend page

In the backend description tab the code is this:

<p><img src="http://root/admin/cms/wysiwyg/directive/___directive/e3ttZWRpYSB1cmw9Ind5c2l3eWcvdHlzc28vcG9zLTEwMDAuanBnIn19/key/b9ccf57c9f11521f13b96a08ec4b73eb40a1056d707329ba67a031d8295aa77b/" width="1140" height="762" /></p>

please note that I added the image via the WYSIWYG editor by clicking on the insert image icon.

 

on the front end the source code of the description tab is this:

<div class="data item content" id="description.tab" data-role="content">
                    <h2>Tysso POS-1000-B</h2>
<h3>Fanless Full Flat Touch Screen POS Terminal</h3>
<p><img src="http://magento/admin/cms/wysiwyg/directive/___directive/e3ttZWRpYSB1cmw9Ind5c2l3eWcvdHlzc28vcG9zLTEwMDAuanBnIn19/key/b9ccf57c9f11521f13b96a08ec4b73eb40a1056d707329ba67a031d8295aa77b/" width="1140" height="762" /></p>
</div>

When I tried to copy the image url generated from source code i will get the login page for the admin backend.

Re: Images not showing in wysiwyg frontend page

@robertbits @Rakesh Jesadiya

If you directly show description which contains Image then that Image without filter will not displayed on frontend!

 

Use Below Function to retrieve Description Content:

    /**
     * Retrieve filtered content
     *
     * @return string
     */
    public function getDescription()
    {   
        $desc = $this->getProduct()->getDescription();
        $key = 'desc_filtered_content';
        if (!$this->hasData($key)) {
            $content = $this->_filterProvider->getPageFilter()->filter(
                $desc
            );
            $this->setData($key, $content);
        }
        return $this->getData($key);
    }
Spoiler
Note: Initialize $this->_filterProvider is you have got error like Undefined Object.

Thank you. 

Re: Images not showing in wysiwyg frontend page

@ronakchauhan427

 

Sorry but I am new to this and I don't know where I need to put the function that you told me.

Re: Images not showing in wysiwyg frontend page

@robertbits

Have you created Block file for your phtml?

 

If yes then you can put this function in it, else you have to override block file.

OR

You can create an helper and get product/Item data and put this function in it.