Editable homepage background image

Semen Shekhovtsov asked on February 5, 2016 17:30

Hello,

Can someone please suggest a way to make homepage background image editable by user, so user can choose from image gallery or alternatively upload a new image. Ideally, user should be able to do it when editing a page. Thanks.

Correct Answer

Joshua Adams answered on February 5, 2016 18:15

You can add a field to whatever document type that you are using and have it as a url selector which points to an image and then include some code such as this:

<style>
    .top-title-img{
      background: url('http://mydomain.com<%= CMS.MacroEngine.MacroContext.CurrentResolver.ResolveMacros("{%CurrentDocument.GetValue(\"myfieldname\")#%}") %>') scroll center no-repeat;
      }
  </style>
1 votesVote for this answer Unmark Correct answer

Recent Answers


Zachary Perry answered on February 5, 2016 17:38

Do you want each user to have their own background image, or an editor to change the site's background image?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on February 5, 2016 17:41

I'd suggest creating a new page type and allowing them to add a new one under the /Home directory. Then using a repeater do display them. In your page type, you can define a title or alternate text field and a text field which is a URL selector to select a file from the media library.

1 votesVote for this answer Mark as a Correct answer

Semen Shekhovtsov answered on February 5, 2016 17:58

@Zachary-Perry , I'm going to integrate an editor to change the site's background image.

0 votesVote for this answer Mark as a Correct answer

Semen Shekhovtsov answered on February 5, 2016 18:02

@Brenden-Kehren page type is Document Type?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on February 5, 2016 20:56

Yes page type = document type in v7 and earlier.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.