Allow image uploads for avatars only?


(Varun) #1

So these are two really basic questions that have probably been asked before, but I haven’t been able to find any relevant topics using the search function

  • To save some disk space I would like to disable image uploads in posts. The issue with setting ‘max image size kb’ to 0 is that it seems to disable profile picture uploads as well, which is something I want to keep. Is there any way to disable image uploads only on posts but keep the option for uploading profile pictures + profile covers?
  • I would like to make the user avatar size on posts bigger (80 x 80 to be precise). However avatar images seem to be saved as 45 x 45 images, which means the image obviously looks bad when it’s scaled. Is there any way to change the size the avatars are saved as?

Again, apologies if these questions have already been covered before!


(Jeff Atwood) #2

Unfortunately I do not think there is any way to do either of these things at the moment. Larger avatar is available though as you can see on the user profile page!


(Varun) #3

Thanks for pointing this out! I shoved this bit of javascript into the header section of my customisation page and it uses the 120 x 120 images on posts now

<script type="text/javascript">

Discourse.Route.reopen({
    activate: function() {
        this._super();
        Em.run.next(function(){
            
            change(); 

        });
    } 
});

function change()
{
    $(".topic-avatar .avatar").each(function(i, obj){
        avatarLink = $(this).attr("src").split("/"); 
        if(avatarLink[1] == "user_avatar") { 
	        avatarLink[4] = "120";
	        var finalLink = avatarLink[0] + "/" + avatarLink[1] + "/" + avatarLink[2] + "/" + avatarLink[3] + "/" + avatarLink[4] + "/" + avatarLink[5];
	        alert(finalLink);
	        $(this).attr("src", finalLink);
        }
    });
}

It’s pretty ugly and probably really inefficient but it gets the job done

EDIT - unfortunately it seems that the JS doesn’t fire when I switch over to another topic, and only applies when I actually refresh the page again? Is there any way to make it fire on topic change?


#4

I would also like to request this feature. I prefer for users to only link to external images in their posts, to save bandwidth and disk space. But I do want avatar uploading.


(Mittineague) #5

Did you already try using Mutation Observer?

* be careful, it can be a massive memory hog


(Stephen Kerr Jr) #6

I would love to use a higher quality avatar as well. Any news on making this available soon? or some sort of hack that will let us do it?


(Jacob Chapel) #7

Here is a post on exactly how to increase your avatar size if you so choose.


(system) #8

(Sam Saffron) #9

I vaguely recall at least thinking about this issue in the past few years. @zogstrip has anything changed here?


(Régis Hanol) #10

We now have the CreateAvatarThumbnails job that will generate a bunch of thumbnails of different sizes (based on the combination of the avatar sizes site setting and some pixel ratios).


(Sam Saffron) #12

Does this mean you can disable all uploads (or heavily restrict upload size) and still allow avatars ?


(Régis Hanol) #14

If you remove all image extensions from the “authorized extensions” site setting, then we won’t show the “Add a custom picture” option in the avatar modal.

I guess you could reduce the “max image size kb” but that will make thumbnails blurry…


(Jeff Atwood) #15

I don’t see this as something we need to contort ourselves to support at the current time.