The image at index 1 in an image gallery component [label=“”] has an invalid value for “document”. “document” must not be null.

Hello, I'm creating an user dashboard, and having some difficulties with a code line

In this dashboard, i show some data from the user, and a profile picture that is already loaded in our files, The problem is, when an user doesnt have a profile picture to be retrieved, the code doesnt work because the field "document" must not be null. I tried using an "If" statement to solve it, but the error keep showing. This is the code that im using: 

*For context only* 

local!data.id_fotoperfil=Profile picture Id

cons!ImagenDePerfilPorDefault= default profile picture

Code:

a!sideBySideItem(
  item: a!imageField(
    labelPosition: "COLLAPSED",
    images: {
      a!documentImage(
        document:
        if(isnull(local!data.id_fotoperfil), cons!ImagenDePerfilPorDefault, local!data.id_fotoperfil))
    },
    size: "MEDIUM",
    isThumbnail: false,
    style: "AVATAR"
),
width: "MINIMIZE"

  Discussion posts and replies are publicly visible

Parents Reply Children
No Data