Jump to content

ImagePicker Field


theo
 Share

Recommended Posts

@MarcoPLY I don't know what it has to do with language.  I can't reproduce your problem. It works here in a multi language setup.

But as it is stated in the README on Github:

Quote

Please check for null before using the return value, because ImagePicker also allows exernal image URLs which do not reference an image object.

So always do this anyway:
 

$img=$page->getInputField('imagepicker')->getImage();
if ($img!=null) {
   ...
}

 

Link to comment
Share on other sites

If I use if ($img!=null) and echo the image not print nothing in the html output.

If I use if ($img == null) in the html I can see the tag img but empty.

This what mean that give me beck an image object, but why do this ? I don't know if you can help me, but where I can check ?

Link to comment
Share on other sites

I really don't know.

It is working here, so there must be something special in your setup.

If you like, you can investigate what is going on in:

private function getAImage($imgpath) in InputfieldImagePicker.module

Thank you.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

I have not been able to understand why in the language change some images return null value while others do not.

So, I inserted the images in this way:

$ima_small = $page->getInputField('image_card')->getImage();
$ima_big = $page->image_card;

if ($ima_small!=null) {
	$ima_small = $ima_small->width(400); // 
	echo '<img class="ima_normal" src="' . $ima_small->url . '">';
   } else {
	echo '<img class="ima_normal" src="' . $ima_big . '">';
   }

Surely it is not the most elegant solution! but maybe this can be used to some one.

  • Like 1
Link to comment
Share on other sites

  • 2 years later...

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...