Lazyload images
This commit is contained in:
		
							parent
							
								
									788ad5eb58
								
							
						
					
					
						commit
						74a3eb2ae0
					
				| 
						 | 
				
			
			@ -27,7 +27,7 @@ void about_route(const httplib::Request& req, httplib::Response& res) {
 | 
			
		|||
 | 
			
		||||
    Element body("body", {
 | 
			
		||||
        Element("a", {{"href", instance.thumbnail}}, {
 | 
			
		||||
            Element("img", {{"class", "about_page-header"}, {"src", instance.thumbnail}}, {}),
 | 
			
		||||
            Element("img", {{"class", "about_page-header"}, {"loading", "lazy"}, {"src", instance.thumbnail}}, {}),
 | 
			
		||||
        }),
 | 
			
		||||
        Element("p", {
 | 
			
		||||
            Element("b", {instance.title, ":"}), " ", instance.description,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -99,11 +99,11 @@ static inline Element user_header(const httplib::Request& req, const std::string
 | 
			
		|||
 | 
			
		||||
    Element header("header", {
 | 
			
		||||
        Element("a", {{"href", account.header}}, {
 | 
			
		||||
            Element("img", {{"class", "user_page-header"}, {"alt", "User header"}, {"src", account.header}}, {}),
 | 
			
		||||
            Element("img", {{"class", "user_page-header"}, {"alt", "User header"}, {"loading", "lazy"}, {"src", account.header}}, {}),
 | 
			
		||||
        }),
 | 
			
		||||
        Element("div", {{"class", "user_page-main_header"}}, {
 | 
			
		||||
            Element("a", {{"href", account.avatar}}, {
 | 
			
		||||
                Element("img", {{"class", "user_page-profile"}, {"alt", "User profile picture"}, {"src", account.avatar}}, {}),
 | 
			
		||||
                Element("img", {{"class", "user_page-profile"}, {"alt", "User profile picture"}, {"loading", "lazy"}, {"src", account.avatar}}, {}),
 | 
			
		||||
            }),
 | 
			
		||||
            Element("span", {
 | 
			
		||||
                Element("b", {preprocess_html(req, account.emojis, account.display_name)}), account.bot ? " (bot)" : "", " (@", account.acct(), ")", view_on_original,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -394,7 +394,7 @@ static Element serialize_post(const httplib::Request& req, const std::string& se
 | 
			
		|||
    Element div("div", {{"class", "post"}}, {
 | 
			
		||||
        Element("div", {{"class", "post-header"}}, {
 | 
			
		||||
            Element("a", {{"href", get_origin(req) + '/' + server + "/@" + post.account.acct(false)}}, {
 | 
			
		||||
                Element("img", {{"class", "post-avatar"}, {"alt", "User profile picture"}, {"src", post.account.avatar_static}}, {}),
 | 
			
		||||
                Element("img", {{"class", "post-avatar"}, {"alt", "User profile picture"}, {"loading", "lazy"}, {"src", post.account.avatar_static}}, {}),
 | 
			
		||||
                Element("span", {
 | 
			
		||||
                    Element("b", {preprocess_html(req, post.account.emojis, post.account.display_name)}),
 | 
			
		||||
                    Element("br"), "@", post.account.acct(),
 | 
			
		||||
| 
						 | 
				
			
			@ -423,7 +423,7 @@ static inline Element serialize_media(const Media& media) {
 | 
			
		|||
    Element element = [&]() {
 | 
			
		||||
        if (media.type == "image") {
 | 
			
		||||
            return Element("a", {{"href", media.url}}, {
 | 
			
		||||
                Element("img", {{"src", media.preview_url.value_or(media.url)}}, {}),
 | 
			
		||||
                Element("img", {{"loading", "lazy"}, {"src", media.preview_url.value_or(media.url)}}, {}),
 | 
			
		||||
            });
 | 
			
		||||
        } else if (media.type == "video") {
 | 
			
		||||
            Element video("video", {{"controls", ""}, {"src", media.url}}, {});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue