Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Strange error with image field type in Mozilla Firefox, images don't output to browser and html code is also strange...


Go to End


2 Posts   1415 Views

Avatar
Bogoed Shamansky

Community Member, 12 Posts

22 October 2014 at 9:19am

Edited: 22/10/2014 10:46pm

OS: Windows7 (On Debian all works fine)
Browser: Mozila Firefox (In Opera and Chrome all works fine)

Problem: Image in path /assets/teasers/_resampled/SetWidth200-kassa.png is exist.
But WTF is class="jelwfmsmflvhwiiehcaz"? And why Firefox don't show this image?

<img class="jelwfmsmflvhwiiehcaz" alt="kassa" src="/assets/teasers/_resampled/SetWidth200-kassa.png"></img>

From my friends computer he has another error, but images also don't show.
In <img> tag style he has something like style="display: none; width=0; height=0".

TeaserPage.php code:

class TeaserPage extends Page
{
    static $can_be_root = false;
	static $has_one = array('TeaserImage' => 'Image');

	public function getCMSFields(){
		$fields = parent::getCMSFields();

		$fields->addFieldToTab
            (   'Root.Main', 
                $uploadField = new UploadField 
                (
                    $name = 'TeaserImage',
                    $title = 'Teaser Image'
                )
            );
		$uploadField->setFolderName('teasers');
		$uploadField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
		$uploadField->setConfig('allowedMaxFileNumber', 1);
        $uploadField->setPreviewMaxWidth(80);
        $uploadField->setPreviewMaxHeight(80);
		return $fields;
	}
}

HomePage.php code:

public function LatestTeasers($teasersNumber=3)
    {
        $holder = TeaserHolder::get()->First();
        return ($holder)
            ? TeaserPage::get()->filter('ParentID', $holder->ID)->sort('ID DESC')->limit($teasersNumber)
            : false;
    }

HomePage.ss code:

<% if $LatestTeasers %>
    <div class="teasers">
        <% loop $LatestTeasers %>
            
<article>
	
	<% if $TeaserImage %>
            $TeaserImage.SetWidth(200)
	<% else %>
		No image
	<% end_if %>
	
    <h2>$Title</h2>
    <p>$Content</p>

</article>

        <% end_loop %>
    </div>
    <% else %>
        No teasers
    <% end_if %>

Avatar
martimiz

Forum Moderator, 1391 Posts

24 October 2014 at 8:50am

Intrigued by that weird classname I googled a bit and found this:

http://stackoverflow.com/questions/23039437/firefox-says-could-not-load-image-for-some-images-adds-weird-classes-automati

That seems to be exactly your problem. Maybe it will set you on the right track...