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

Media field translated script should be improved #15109

Open
sebastienros opened this issue Jan 16, 2024 · 1 comment
Open

Media field translated script should be improved #15109

sebastienros opened this issue Jan 16, 2024 · 1 comment

Comments

@sebastienros
Copy link
Member

https://github.com/OrchardCMS/OrchardCore/blob/main/src/OrchardCore.Modules/OrchardCore.Media/Views/MediaField-Attached.Edit.cshtml#L43

The translation should go in a separate tag and be read by the script to inject the name and size.

@DonaldDWebster
Copy link

https://github.com/OrchardCMS/OrchardCore/blob/main/src/OrchardCore.Modules/OrchardCore.Media/Views/MediaField-Attached.Edit.cshtml#L43

The translation should go in a separate tag and be read by the script to inject the name and size.

Are you referring to a fix like the one below? I'm still getting familiar with the codebase, so I'm trying to better understand your suggestion. Thanks for your help!

<label class="selected-media-name form-label">
    <code class="text-end" v-if="selectedMedia">
	<span v-html="getTranslatedSelectedMediaNameAndSize"></span>
    </code>
</label>

<script at="Foot">
	function getTranslatedSelectedMediaNameAndSize() 
	{
		const fileName = this.selectedMedia.attachedFileName || this.selectedMedia.name;
		const mediaText = this.selectedMedia.mediaText ? `, ${this.selectedMedia.mediaText}` : '';
		const fileSize = isNaN(this.selectedMedia.size) ? 0 : Math.round(this.selectedMedia.size / 1024); //bytes to KB

		return `${fileName}${mediaText} (${fileSize} KB)`;
	}
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants