Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ALTER FUNCTION [dbo].[rs_webpImage]
- (
- @resourceID int,
- @thumb bit = 0,
- @alt nvarchar(max) ='',
- @class nvarchar(64) = '',
- @width nvarchar(20) = '',
- @height nvarchar(20) = ''
- )
- RETURNS nvarchar(256) as
- BEGIN
- declare @res nvarchar(256) = ''
- declare @url nvarchar(256) = (select iif(@thumb=1, thumbUrl, url) from as_rs_resources where id = @resourceID)
- declare @webpUrl nvarchar(256) = replace(@url, reverse(left(reverse(@url), charindex('.', reverse(@url)) - 1)), 'webp')
- declare @cl nvarchar(256) = iif(@class<>'', ' class="'+@class+'" ', '')
- declare @w nvarchar(256) = iif(@width<>'', ' width="'+@width+'" ', '')
- declare @h nvarchar(256) = iif(@height<>'', ' height="'+@height+'" ', '')
- set @res = '
- <pic'+'ture'+@cl+'>
- <so'+'urce srcset="'+@webpUrl+'" type="image/webp" loading="lazy" alt="'+@alt+'" '+@w+' '+@h+'>
- <i'+'mg src="'+@url+'" alt="'+@alt+'" '+@w+' '+@h+'>
- </pict'+'ure>
- '
- return lower(@res)
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement