#1 March 5, 2016 11:30am

Terrra-Robin
Member
Registered: February 7, 2016
Posts: 61

Black (broken?) images when using crop.

Hello,

I've been trying to use cropped images on my website for a slider on the homepage. But when I want to display an image, everything is black. I also can't see a crop preview when I upload a file, but when I hit "upload" I don't have any errors or something... And there is a (black) image file uploaded in the right directory .

Do you guys know what I did wrong?

Offline

#2 March 5, 2016 11:37am

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 974

Re: Black (broken?) images when using crop.

I've noticed this happening recently as well -- in the cases I've seen there was a directory permissions issue with where the image would be uploaded. I'd check Developer -> Site Status to see if any errors about permissions are raised.

It's in the bug list to check on why it's not properly throwing an error when uploading.

Offline

#3 March 5, 2016 12:58pm

Terrra-Robin
Member
Registered: February 7, 2016
Posts: 61

Re: Black (broken?) images when using crop.

Hello,

Thanks for the quick response! When I look in Developer -> Site Status I don't see any errors. Only a warning from the favicon.

Do I need to make extra fields in the module table for cropped images?  I don't see a link to a cropped image in the database table either. What does "preview prefix (for forms)" do by the way? do I need to set something there? And does it matter what I set?

Thank you in advance.

Offline

#4 March 6, 2016 6:09pm

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 974

Re: Black (broken?) images when using crop.

You shouldn't need extra fields for cropping images -- only the primary image name is served in the database. All the additional crops / thumbnails you generally give prefixes to (i.e. large_). If you give your crop a prefix you reference it using the BigTree::prefixFile method. For example:

<img src="<?=BigTree::prefixFile($item["image"],"large_")?>" alt="">

The "Preview Prefix (for forms)" allows you to enter one of the prefixes you're using so that when you edit things in the CMS it loads one of the smaller thumbnails or crops instead of the original image -- this helps a lot if your source images are huge so that you don't slow down editors by loading the giant image. You don't need to put anything there if you don't want to.

Offline

#5 March 9, 2016 9:02am

Terrra-Robin
Member
Registered: February 7, 2016
Posts: 61

Re: Black (broken?) images when using crop.

Allright, thanks! I've used the method you mentioned but it's still not working. I am displaying content from a module by the way. Maybe that makes a difference?

This is what I have:

<ul class="bxslider">
<?
	$homeSlider = new HomeSlider();
	$sliders = $homeSlider->getApproved(3);
	foreach ($sliders as $slideItem) {
		$image = $slideItem['slide_image'];
		
		$thumb_image = BigTree::prefixFile($image, "thumbslide_"); 
		?>
		
			<li>
				<div class="wrapper">
					<img src="<?=$thumb_image?>">
					<div class="slideDescription">
						<span class="redSpan"><?=$slideItem['slide_heading']?> |</span>
						<span class="graySpan"><?=$slideItem['slide_subheading']?></span>
						<p><?=$slideItem['slide_description']?></p>
						<a href="<?=$slideItem['slide_link']?>" alt=""><?=$slideItem['button_text']?></a>
					</div>
				</div>
			</li>
	<?}
?>
</ul>

Offline

#6 March 9, 2016 9:14am

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 974

Re: Black (broken?) images when using crop.

Does the image it's looking for exist on the file system? All the code above looks good to me.

Offline

#7 March 9, 2016 9:15am

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 974

Re: Black (broken?) images when using crop.

Just thought of something else -- are you by chance using a Windows server for hosting? Windows/PHP often don't properly report file system permissions so if you are on Windows you may have a permissions issue with writing to the directory that BigTree can't see.

Offline

#8 March 10, 2016 6:39am

Terrra-Robin
Member
Registered: February 7, 2016
Posts: 61

Re: Black (broken?) images when using crop.

Thanks for thinking with me! I have found the problem. In the module there was set a varchar (255) for the upload field. I think the file names were too long becouse of the prefix. I changed it to text and after that everything was working perfectly smile
It think varchar (255) is the default setting for upload fields. Maybe it's good to consider an extended limit on the default upload field in module builder, becouse pictures taken with a phone usually have long file names with a date and that kind of stuff. (If it's not the default setting: I've said nothing wink )

Offline

#9 March 10, 2016 9:37am

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 974

Re: Black (broken?) images when using crop.

That's good to know! It probably is the case that the Module Designer sets fields to varchar(255) when creating them.

Out of curiosity, what was the filename that was trying to be stored that ended up so long? smile

Offline

#10 March 10, 2016 12:32pm

Terrra-Robin
Member
Registered: February 7, 2016
Posts: 61

Re: Black (broken?) images when using crop.

One of the longest was: "smallpicture_img_20150911_142804-2.jpg"
Hmm, not that long actually.. hehe
So the limit wasn't the issue I think...
I'm also curious about what's wrong with a varchar. It should be working fine I think.

Offline

Board footer

Powered by FluxBB

The Discussion Forum is not available on displays of this size.