Jump to content

Alternative image not detected on production server? :(


Xonox
 Share

Recommended Posts

Hi,

There's something happening in ProcessWire that doesn't compute abd it has to do with images.

Situation:

On the homepage template there's a repeater that takes two images to build a slider:

slide_image: A wide image for desktops
slide_image_mobile: A more "verticalized" image for small screens

Now I have this code:

foreach($page->home_slides as $slide) {

	// Create desktop slide
	if(isset($slide->slide_image)) {

		// Create desktop slide
		$slide_image = $slide->slide_image->size(1170,400);

		// Create mobile slide
		if(isset($slide->slide_image_mobile)) {
			$slide_image_mobile = $slide->slide_image_mobile->size(1048,800);
		}
		else {
			$slide_image_mobile = $slide->slide_image->size(1048,800);
		}

		?>
			<div class="slide-content">
				<a href="<?php echo $slide->link; ?>" class="slide">
					<img src="<?php echo $slide_image->url; ?>" class="img-fluid d-none d-md-block" title="<?php echo $slide->slide_title; ?>" alt="<?php echo $slide->slide_title; ?>" />
					<img src="<?php echo $slide_image_mobile->url; ?>" class="img-fluid d-block d-md-none" title="<?php echo $slide->slide_title; ?>" alt="<?php echo $slide->slide_title; ?>" />
				</a>
			</div>
		<?php

	}

}

On my dev server, the small image is detected and placed in content, however in my production server this doesn't happen.

I've double checked fields names and the fields contain images. I've even imported the database into the Dev Server.

I don't have any clue why it works locally and not in server.

Can anyone shed som light?

Thank you!

Link to comment
Share on other sites

2 minutes ago, BitPoet said:

Any chance that it could be a file system permissions issue on the production server in the site/assets/files path?

I checked and it looks fine. To clarify:

slide_image - is detected and used;
slide_image_mobile - site behaves as it doesn't exist!

Both have same permissions.

I changed the code to the following to force the use of slide_image_mobile:

foreach($page->home_slides as $slide) {
	$slide_image_mobile = $slide->slide_image_mobile->size(1048,800);
	?>
	<img src="<?php echo $slide_image_mobile->url; ?>" class="img-fluid d-block d-md-none" title="<?php echo $slide->slide_title; ?>" alt="<?php echo $slide->slide_title; ?>" />
	<?php
}

Which gives a Fatal Error (Call to a member function size() on null) which makes sense.

But the image is there! ?

Link to comment
Share on other sites

Update: I also can´t delete the slide_image_mobile images, which should be unique (only one image). It keeps adding images despite the field being set with only one image and "One element null if empty".

Link to comment
Share on other sites

On 3/8/2019 at 11:00 PM, Robin S said:

Related?

 

It looks related, but I still can't get it to work. There are some new inputs:

1. The field is inside a repeater;
2. Despite the field being set to have only one image, in some cases it has more than one that I can't delete;
3. Tried to change files' permissions but it still doesn't work;
4. It's impossible to delete the images, but when I load a new one, it replaces one of the old ones.

I'm a bit lost with this one. ?

Link to comment
Share on other sites

Update: If the field is outside a repeater, it works fine!

In my dev server, everything works fine inside the repeater.
In production server, the field inside the repeater doesn't work as it should.
Inside repeater, I can't even edit image descriptions.
Field outside the repeater works fine on both machines.

I just remembered that I had this problem before, on another site, but never got solved:


This is getting a bit annoying! ?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...