Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Url.Kentico().ImageUrl(...), not @Url.KenticoImageUrl(...) #23

Closed
jschrab-lc opened this issue Feb 13, 2019 · 1 comment
Closed

@Url.Kentico().ImageUrl(...), not @Url.KenticoImageUrl(...) #23

jschrab-lc opened this issue Feb 13, 2019 · 1 comment
Assignees

Comments

@jschrab-lc
Copy link

Brief bug description

I suspect a minor code error in Views/Doctors/Detail.cshtml. The following line...

<img src="@Url.KenticoImageUrl(Model.Data.Doctor.Photo.GetPath())" alt="Doctor's photo" />

Repro steps

  1. Add repo to project solution
  2. Attempt to build
  3. See error

Expected behavior

I believe the correct code would be...

<img src="@Url.Kentico().ImageUrl(Model.Data.Doctor.Photo.GetPath(), SizeConstraint.Empty)" alt="Doctor's photo"/>

Test environment

  • Version - Kentico v12.0
@Enngage
Copy link
Contributor

Enngage commented Feb 14, 2019

Thank you for submitting the issue! In general you would be correct, but in this case it is intentional because we want to separate Kentico API from MVC project (and other libraries for that matter) as much as we can. For that reason we created an extension method using the KenticoImageUrl signature that you can find here: https://github.com/Kentico/training-kentico-k12/blob/master/MedioClinic/Extensions/UrlExtensions.cs

Basically you wrap Kentico code in your own so that you have more control over it, you don't 'pollute' your views with Kentico code/namespace which then results in better maintainability/extensibility and upgradability.

@Enngage Enngage closed this as completed Feb 14, 2019
@Enngage Enngage self-assigned this Feb 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants