ImageTagHelper in the Media module provides an asset-src attribute for img tags to easily generate images with proper URL. We could have the same for the a tag too, so links can be easily generated too.
Since this just needs another HtmlTargetElement on the class, maybe a good first issue?
I will try to get this done tonight as my first contribution to this project. I guess I cannot assign it to myself until I submit my first PR and become a contributor, right?
Great Marcelo!
@mbarsott I assign it to you ;) please let us know if you need a help
@mbarsott I assign it to you ;) please let us know if you need a help
Thank you @hishamco. This is my first time contributing to an OSS, and also using the forked model in Github; please forgive me if I ask too many questions.
I am getting familiar with Razor TagHelpers implementations, so I think this may take a couple of days.
I forked, then cloned locally and branched from dev. I assume I will submit the PR requesting to merge this new branch from my forked repo into OrchardCore's repo, dev branch, right?
Just push the PR to your fork, then it's automatically will trigger the OC repo, all the best for your first PR
Thanks
I'm sorry, but now that I understand more about Razor Tag Helpers, I don't understand the initial description of this enhancement. The asset-src attribute defined in the ImageTagHelper serves the purpose of replacing the src attribute value on an img element with the resolved public URL for the image file. Simply adding another HtmlTargetElement to the class, as suggested in the initial comment, would simply set the src attribute value on an a element. Of course this is not the intent of this enhancement, as there is no src attribute in the HTML specification for anchor tags. I imagine the author meant to have the tag helper generating something for the href attribute, since he says 'so links can be easily generated', right? Could you please elaborate more on the intended use of the tag helper for anchor tags? One example, maybe? Thank you.
@mbarsott I assume he meant like <img asset-src=“”> generates img tag for images stored in media library, <a asset-href=“”> will generate links to css/js assets stored in media library
@mbarsott yes, as @ns8482e suggests.
It's useful if you want to generate a link to a pdf (for example), rather than an img tag to an image
I probably wasn't clear enough and actually totally missed on the attribute name. So yeah, the idea is that just as how you write <img asset-src="..."> today you could write <a asset-href="...">. While this can't be done by just an HtmlTargetElement alone, you can add the capability to the existing tag helper along the lines of what's explained here: https://stackoverflow.com/a/46719088/220230
@mbarsott any progress on this one?
@mbarsott any progress on this one?
I'm sorry, I had been very busy at work. I will try to get it finished in the next couple of days.
I probably wasn't clear enough and actually totally missed on the attribute name. So yeah, the idea is that just as how you write
<img asset-src="...">today you could write<a asset-href="...">. While this can't be done by just anHtmlTargetElementalone, you can add the capability to the existing tag helper along the lines of what's explained here: https://stackoverflow.com/a/46719088/220230
Thank you for your explanation. If I understood it correctly, the idea is to create a tag helper for links (anchor tags) in the Media module, so users can create links on their pages for assets in the Media Library, right? In that case I intend to use the same .Net Core naming standard, for the class, AnchorTagHelper, just like it was done with ImageTagHelper, and, for consistency sake, the attribute name will be asset-src, right? Please, correct me if I am wrong.
If I understood it correctly, the idea is to create a tag helper for links (anchor tags) in the Media module, so users can create links on their pages for assets in the Media Library, right?
Yes, exactly.
AnchorTagHelper, just like it was done with ImageTagHelper, and, for consistency sake, the attribute name will be asset-src, right?
The attribute can be asset-href so it's similar to the HTML attribute, not specifying this was just an omission on my part. Also, I don't think you need a separate tag helper class as the behavior would be exactly the same as with ImageTagHelper and as it's explained in the SO post I've linked you can pretty much alias both the attribute name.
Pull Request #6611 submitted. Also resolved some comments about the use of constants instead of string literals.
Most helpful comment
I will try to get this done tonight as my first contribution to this project. I guess I cannot assign it to myself until I submit my first PR and become a contributor, right?