0

From SharePoint Online, I have a Hyperlink or Picture column which I am using for Picture. If the user does did not supply a picture for this column, it will look something like this.

enter image description here

When not in edit mode, how can I either:

  • Replace that default picture for another picture in this column
  • Remove the default broken picture all together for this specific instance (i.e. hide it with conditional formatting)
  • Use JSON (conditional formatting) to set CSS to display none on this column, or set background-color to white for column

all if the user did not provide a picture, all in Gallery View.

Are any of these steps possible today with SharePoint Online?

update

If you look through the console, on a list that is in Gallary mode, I would like to remove this default code for the default picture icon loaded through SharePoint. I want to remove it or change it up. I want to place my own custom default image here instead.

<svg style="display:;" preserveAspectRatio="none" viewBox="0 0 210 105" class="sp-card-defaultImage ms-bgColor-themeLighter" focusable="false"><path id="sp-card-defaultImage-path1" d="M0 25.7896L126.5 53.8817L96 105H0V25.7896Z"></path><path id="sp-card-defaultImage-path2" d="M96 105L158.7 0H204C207.314 0 210 2.68629 210 6V105H96Z"></path></svg>

1 Answer 1

1

In SharePoint JSON formatting, you can get the hyperlink/picture column value using:

[$Picture]

Picture is internal name of hyperlink/picture column. You can get the internal name of your column by following this article: How to find the Internal name of columns in SharePoint Online?

Also, you can get the description of hyperlink/picture column using:

[$Picture.desc]

Hiding hyperlink/picture column from list form:

Use conditional formula on column like:

=if([$Picture], true, false)

Hiding hyperlink/picture column in JSON formatting:

"style": {
    "display": "=if([$Picture], 'block', 'none')"
}

Use default image in JSON formatting if Picture column is blank:

{
  "elmType": "img",
  "attributes": {
    "src": "=if([$Picture], [$Picture], '<default-image-url>')"
  }
}

Replace <default-image-url> with the URL of default image to show if Picture column is blank.


Update from Comments:

If you want to hide the default preview from "Gallery View"", follow below steps:

  1. Open Gallery view in your list
  2. Select "Format current view" from "Switch view options" dropdown
  3. Select "Edit card" under "Card Designer"
  4. Turn off toggle button near Show preview
  5. Click Save

enter image description here

Note that it will hide preview for all list items and not conditionally based on Picture column value.

4
  • in your last example, does the fallback path to the image, have to be absolute?
    – klewis
    Mar 26, 2021 at 16:15
  • In JSON formatting, you can get the absolute URL for the site using @currentWeb. So if you want to give the URL of picture from another document library, you can use something like: @currentWeb + '/DocumentLibrary/MyImage.png' Mar 26, 2021 at 16:38
  • Can you please add to your excellent answer that if anyone wants to hide the default icon for picture that loads, from Gallery view....make sure you are in Gallery mode, then select "Format Current View", then Card Designer, then uncheck "Show Preview". This will remove the default card from the list, but still allow JSON on the actual picture when viewing that specific Record.
    – klewis
    Mar 26, 2021 at 19:30
  • Done. Note that it will hide preview for all list items and not conditionally based on Picture column value. Mar 27, 2021 at 7:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.