Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I am trying to use the name of the image file for the alt tag in the Media editor section, how will i go about this and also would aslo like it to drop the .png or .jpg etc.. also
@if (Model.value != null){ var url = Model.value.image; var urlName = ""; if(Model.editor.config != null && Model.editor.config.size != null){ url += "?width=" + Model.editor.config.size.width; url += "&height=" + Model.editor.config.size.height; if(Model.value.focalPoint != null){ url += "¢er=" + Model.value.focalPoint.top +"," + Model.value.focalPoint.left; url += "&mode=crop"; } } <img src="@url" class="img-responsive2" alt="">}
Hi David,
Agree with you that Monday is hard day :)
You can try Path.GetFileNameWithoutExtension method:
string fileName = @"C:\mydir\myfile.ext"; string result = System.IO.Path.GetFileNameWithoutExtension(fileName);
Thanks,
Alex
Yeah that is brilliant just what i need, need to figure out how to get the file name to string first into the alt tag :-(
url.ToString()
Yeah thats what i have done so far but that gives me the full media url :-(
Another one:
string stringUrl = url;
string fileName = url.ToString(); string result = System.IO.Path.GetFileNameWithoutExtension(fileName);
Got it i had used the first varible in the alt tag, theses mondays are a killer :-( i had used @fileName #sillyme
)) So ) Is it fixed?
Yip all working now, your a star :-)
@if (Model.value != null){ var url = Model.value.image; var urlName = url.ToString(); string result = System.IO.Path.GetFileNameWithoutExtension(urlName); if (Model.editor.config != null && Model.editor.config.size != null) { url += "?width=" + Model.editor.config.size.width; url += "&height=" + Model.editor.config.size.height; if (Model.value.focalPoint != null) { url += "¢er=" + Model.value.focalPoint.top + "," + Model.value.focalPoint.left; url += "&mode=crop"; } } <img src="@url" class="img-responsive2" alt="@result"> // if (Model.value.caption != null) //{ // <p class="caption">@Model.value.caption</p> // } }
Cool, glad to help you ) Can you mark topic solved?
Write if something else.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Monday Morning Brain Freeze - Help :-)
I am trying to use the name of the image file for the alt tag in the Media editor section, how will i go about this and also would aslo like it to drop the .png or .jpg etc.. also
Hi David,
Agree with you that Monday is hard day :)
You can try Path.GetFileNameWithoutExtension method:
Thanks,
Alex
Yeah that is brilliant just what i need, need to figure out how to get the file name to string first into the alt tag :-(
Yeah thats what i have done so far but that gives me the full media url :-(
Another one:
Got it i had used the first varible in the alt tag, theses mondays are a killer :-( i had used @fileName #sillyme
)) So ) Is it fixed?
Yip all working now, your a star :-)
Cool, glad to help you ) Can you mark topic solved?
Write if something else.
Thanks,
Alex
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.