Media Library paths contain admin domain instead of live site

Nate Axtell asked on May 1, 2023 20:22

I have a Kentico v12.0.92 MVC website. In the Media Library app when I click on an item in the library and view the Direct Path and Permanent Link, both show the Admin domain.

I have another v12.0.100 MVC site where I see the same thing, the preview links show the Admin domain.

I then have two v12.0.100 WebForm site examples where I see the Live site domain.

For the v12 MVC development model, do I have options to change the Media Library preview links so they don't show the Admin URL and show the Live site URL instead? This is a client request since they sometimes copy from here and share externally, but their Admin domain is now IP-restricted.

Recent Answers


Juraj Ondrus answered on May 2, 2023 05:45

How are the links saved in the content? You need to keep in mind that in MVC model are two separate apps. So, when working in the admin app, the link must be to the admin app. But when displaying the media file on the MVC live site, the domain name should be the live site domain as the links should be parsed and saved in a relative path format to the content. It is not good idea to copy the links from the admin UI and send them externally. It would be better to place the media file on some page and send the preview link to the page. Or, before sending the link, changing the admin domain name to the live domain manually.

0 votesVote for this answer Mark as a Correct answer

Nate Axtell answered on May 2, 2023 15:09 (last edited on May 2, 2023 15:10)

How are the links saved in the content? So, when working in the admin app, the link must be to the admin app.

In content the links are all relative to the live site. In the Kentico v13 MVC model, the admin interface preview links are not relative to the admin app, they point to the live site. I was hoping there was some configuration where I could achieve the same in v12 MVC.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 2, 2023 19:22

When you are viewing/testing this out, you cannot use Inspect, you have to use view source to verify what was actually rendered. Most browsers will automatically generate the relative URL with the domain that the site is currently on. So viewing the source of the page will help you verify closer what is actually being rendered and how you might correct it.

0 votesVote for this answer Mark as a Correct answer

Nate Axtell answered on May 2, 2023 19:49

I double-checked the response of the XHR requests for K12 and K13 in the Media Library app. K12 returns a relative path and K13 returns a full path with the live site domain. This is the page that receives the POST. /CMSModules/MediaLibrary/Tools/Library_Edit_Files.aspx?objectid=9

It seems the general consensus is that there are no configuration options to control this behavior in K12. Thanks for your responses.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 2, 2023 19:52

Not configurable but what specifically are you looking to accomplish?

0 votesVote for this answer Mark as a Correct answer

Nate Axtell answered on May 2, 2023 20:06

We took over a client from another agency where the client had been copying the Prod-relative PDF and Image links and using it for external purposes, think email campaigns. The client IP-restricted their admin domain so that these asset links no longer work publicly. We have a request to make the preview-links in the Media Library relative to the live site, like the behavior in K13.

I realize that I could dig through Library_Edit_Files.aspx to potentially customize the URL construction, but this seems dangerous and an area that I wouldn't suggest to the client that we customize.

Since the client can't really be sharing assets that often, it seems like a more practical approach is to just have them manipulate the URL that they copy from the preview links.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 2, 2023 20:16

You could modify your views to handle this.

But technically speaking if the CMS and MVC sites are set up properly, this URL:

https://domain.com/getmedia/15b542fd-e2ee-47e6-9212-c3fa733eb3a8/your-image.jpg

and this url:

https://admin.domain.com/getmedia/15b542fd-e2ee-47e6-9212-c3fa733eb3a8/your-image.jpg

should both work without issue and return the same path. So if they were copying the URL from the Media Library link, then tell them to simply modify the URL (remove "admin.") to be that of the public facing website. The image should work just fine and if they are already used to copying that URL it's a slight modification from what their current process is.

0 votesVote for this answer Mark as a Correct answer

Nate Axtell answered on May 2, 2023 21:30

For the Admin site, I looked at the the control files for MediaLibrary.ascx. I see the setting for IsLiveSite, but changing it to "true" doesn't have an affect. Otherwise, the control is too complex to consider making any changes, especially since they'd have to be reviewed and maintained on any upgrades (short of upgrading to K13 where customizations could be discarded).

<ContentTemplate>
    <cms:MediaLibrary ID="libraryElem" ShortID="l" runat="server" DisplayFilesCount="true"
        IsLiveSite="false" DisplayMode="Simple" />
</ContentTemplate>

But yes, modifying the URL to replace "admin." with "www." is what I was explaining above. I'll move forward with this as the solution. Thanks again for your suggestions.

0 votesVote for this answer Mark as a Correct answer

Nate Axtell answered on May 3, 2023 15:20 (last edited on May 3, 2023 15:21)

what are your Presentation and Administration URL setting?

The admin URL is a subdomain, "admin.{domain}.com". Presentation URL is "www.{domain}.com".

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 3, 2023 16:22

Does the presentation URL have the HTTP(s):// in front of it?

0 votesVote for this answer Mark as a Correct answer

Nate Axtell answered on May 3, 2023 16:30

Does the presentation URL have the HTTP(s):// in front of it?

Yes, it does. I should have written above, "https://www.{domain}.com".

0 votesVote for this answer Mark as a Correct answer

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