Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Så här förhindrar du att WordPress genererar storlekar på images

När du laddar upp en bild i WordPress skapas automatiskt flera kopior i olika storlekar. Olika teman och plugins kan ytterligare öka antalet storlekar som genereras.

Detta tar upp mycket utrymme i din databas och saktar ner webbplatsens hastighet. Det ökar även storleken på webbplatsens backupfil.

På WPBeginner har vi skrivit hundratals handledningar om WordPress-optimering och webbplatshantering. Detta har gett oss en djupare förståelse för WordPress inre funktioner och gör att vi kan ge dig tips för att bättre hantera dina bilder.

I den här artikeln visar vi dig hur du steg för steg kan förhindra att WordPress genererar storlekar på bilder.

How to Prevent WordPress from Generating Image Sizes

Varför hindra WordPress från att generera storlekar på images?

När du laddar upp en bild till din WordPress-webbplats genereras automatiskt flera kopior av bilden i olika storlekar. Som standard genereras förutom originalbilden även storlekarna thumbnail, medium size och large size.

WordPress themes och tillägg kan också skapa ytterligare storlekar på images. Du kanske upptäcker att du har 5 eller 10 kopior av varje image i olika storlekar.

WordPress Automatically Creates Copies of Your Images in Different Sizes

De olika storlekarna på images genereras och lagras under upload-processen. Detta kommer inte att påverka dina visitors eller göra din WordPress site långsammare, men det kräver lite mer lagringsutrymme.

Det extra utrymme som dessa extra images tar i anspråk är normalt sett inget problem. De flesta WordPress hosting providers erbjuder generöst med diskutrymme, vilket räcker för att lagra tusentals images.

Med detta sagt kanske vissa användare vill hindra WordPress från att generera så många standardstorlekar på images.

När användare med tusentals images säkerhetskopierar sina websites kan de till exempel upptäcka att deras backup har blivit mycket stor och tar längre tid att completed. Andra användare upptäcker att de inte använder vissa storlekar på images all, och att inaktivera dem sparar lagringsutrymme.

Du bör dock vara försiktig med att ta bort storlekar på images. De kan behövas av ditt theme för inläggsminiatyrer, sliders, attachments eller custom post types. Ta bara bort dem om du är säker och medveten om vilken effekt det kan ha på din site.

Med detta sagt, låt oss ta en titt på hur du kan förhindra WordPress från att generera bildstorlekar. Vi kommer att visa dig två olika metoder, samt en bonusmetod för att inaktivera sidor med bildbilagor:

Det enklaste sättet att förhindra WordPress från att generera bildstorlekar är att använda plugin-programmet WPCode.

WPCode är det bästa kodsnippets-pluginet för WordPress. Det gör att du enkelt kan lägga till anpassad kod i WordPress utan att redigera ditt temas functions.php-fil, så du behöver inte oroa dig för att förstöra din webbplats.

Dessutom levereras WPCode med ett inbyggt bibliotek med färdiga kodavsnitt för populära funktionsförfrågningar, inklusive inaktivering av miniatyrbildstorlekar.

För att komma igång måste du installera och aktivera det kostnadsfria WPCode-pluginet. För detaljerade instruktioner, se vår guide om hur du installerar ett WordPress-plugin.

Efter aktivering går du till Code Snippets ” Library från WordPress adminpanel.

Sök sedan efter utdraget ”Disable Thumbnail Image Sizes” och klicka på knappen ”Use snippet”.

Search for the Disable Thumbnail Image Sizes snippet in the WPCode library

WPCode kommer sedan automatiskt att lägga till koden åt dig. Den här koden kan inaktivera flera specifika bildstorlekar som miniatyrbild, medium, medium stor, stor och mer.

Du måste ta bort // från de bildstorlekar som du vill inaktivera.

WPCode automatically adds the code

Efter det behöver du bara växla från ”Inaktiv” till ”Aktiv” och klicka på knappen ”Uppdatera” högst upp på sidan.

Switch the toggle to 'Active' and click the 'Update' button

Nu är det klart. Nu skapas inga extra miniatyrstorlekar när du laddar upp bilder i WordPress.

Metod 2: Hur man förhindrar WordPress från att generera bildstorlekar med ett plugin

Den här metoden är för dem som föredrar att använda ett plugin

Först måste du installera och aktivera ThumbPress-pluginet. Om du behöver hjälp kan du läsa vår nybörjarguide om hur du installerar ett WordPress-tillägg.

Vid aktivering, besök sidan ThumbPress ” Moduler från din WordPress instrumentpanel och växla reglaget Inaktivera miniatyrbilder” till Aktiv”.

När du har gjort det klickar du på knappen ”Save Settings” för att spara dina ändringar.

Toggle the Disable Thumbnails switch

Ett sidofält kommer nu att visas i skärmens vänstra kolumn. Härifrån måste du välja alternativet ”Inaktivera miniatyrbilder”.

Då öppnas en ny sida. På vänster sida av skärmen kommer du att märka att alla ytterligare bildstorlekar listas. De som är markerade med rött anger att dessa storlekar är aktiverade och kommer att genereras.

Select the Disable Thumbnails option from the column on the left

Du måste dra varje storlek som du inte vill ha till den högra Column. Detta inaktiverar den så att den inte genereras när du uploadar en image.

You kan till exempel välja att ta bort all thumbnail-storlekar.

När du har dragit varje bildstorlek till höger kommer dessa bilder nu att visas i grönt.

Disable image sizes

Se till att du klickar på knappen ”Save Settings” för att aktivera dina nya inställningar.

När du nu laddar upp nya bilder på din WordPress-blogg kommer inga extra bildstorlekar att genereras.

Bonus: Inaktivera bilagssidor för images i WordPress

Förutom att ta bort olika bildstorlekar kanske du också vill inaktivera bilagssidorna för bilder på din website.

Som standard skapar WordPress en enda page för varje media attachment på din site, inklusive images, ljud och videoklipp. Dessa pages visar bara själva imagen utan någon text eller content, vilket kan ge ett dåligt intryck hos användarna.

Dessutom kan det också skada din sites sökmotorsoptimering eftersom search engines värdesätter högkvalitativt content, och bilagssidor saknar sammanhang. I det här fallet är det en bra idé att inaktivera bilagssidor på din website.

Du kan enkelt göra detta med All in One SEO för WordPress, som är det bästa sökmotorsoptimeringsverktyget på marknaden.

All in One SEO

Installera bara pluginet och besök All in One SEO ” Search Appearance page från WordPress dashpanelen.

Här byter du till tabben ”Image SEO” och väljer alternativet ”Attachment Parent” i sektionen ”Redirect Attachment URLs”. Nu, när en användare landar på bilagssidan för bilden, kommer de att redirectas till ditt blogginlägg istället.

Select Attachment parent option

När du är klar, glöm inte att clicka på knappen ”Save Changes” för att store dina inställningar. För detaljerade instruktioner, se vår tutorial om hur du inaktiverar bilagssidor för images i WordPress.

Du kan också använda AIOSEO för XML-webbplatskartor, en skrivassistent, Image SEO, en assistent för trasiga länkar, AI meta beskrivningar och så mycket mer.

För detaljer, se vår kompletta All in One SEO review.

Vi hoppas att denna tutorial hjälpte dig att lära dig hur du förhindrar WordPress från att generera image-storlekar. Du kanske också vill se våra WordPress tutorials om hur man skapar en landing page med WordPress och våra expertval för de bästa WordPress-tilläggen för bildkomprimering.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Avslöjande: Vårt innehåll stöds av våra läsare. Det innebär att om du klickar på några av våra länkar, kan vi tjäna en provision. Se hur WPBeginner finansieras, varför det är viktigt, och hur du kan stödja oss. Här är vår editoriala process.

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

Den ultimata WordPress-verktygslådan

Få GRATIS tillgång till vår verktygslåda - en samling WordPress-relaterade produkter och resurser som varje professionell användare bör ha!

Reader Interactions

39 kommentarerLämna ett svar

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Jiří Vaněk says

    This is a very useful feature that I will gladly use. I have nearly 1,000 articles on my website, and practically every one of them contains images. WordPress generates these images in many sizes, and thus the website now takes up almost one and a half gigabytes, which is relatively a lot. This will help me save space because I don’t use many of these sizes at all. I just have one question regarding the image sizes: is it possible to delete previously generated images to save space on FTP?

  3. Daphne says

    Thank you! I transitioned a site over to Divi, then added several galleries. Was blown away buy the file storage glut. This easy solution brought the total storage down to something managable.

  4. Jenn Summers says

    Hi, today I changed all my settings to 0 like shown in your instructions above. I uploaded a new picture and when I attempted to resize in side bar all I have for options is full size (which is too big) and shareaholic from another plugin in my site. I tried setting back to default settings. And it didn’t change still same two options. Any idea how I can fix this?

  5. javidan says

    HI
    how to prevent WP to generate variety image size for all images?
    in a single post we have 6-7 image and wp will generate 3 size for all of them that not be used except thumbnail
    and another question is make gallery but google crawl that page of that single image why?

  6. Scott says

    Does not work. You have to modify the functions.php flle. This is one of the most irritating thing WP does. You should be prompted to create multiples sizes after uploading files. It should not be assumed. Bad bad…

  7. Amit says

    Hello,
    I have a running image sharing website, usually, we insert more than 20 images in a single post. I want to prevent WordPress from generating different image sizes for inserted images, except for the post featured image.

    For example, If there are 20 images in my post. I want WP to generate image sizes for the Featured image only, and for other inserted images i don’t want different sizes.
    Actually, the problem is the limited storage space and the other problem is that with those useless image sizes the backup file has more size.

    How can I achieve this?
    I appreciate your help.

      • WPBeginner Support says

        Hi Lalit and Amit,

        Unfortunately, this is not as straightforward. Your WordPress theme may have defined its own image sizes, some times WordPress plugins may also define new image sizes. First you will need to figure out the sizes you don’t want to use anymore. This may result in unexpected behavior from your theme and or plugin. You will need to know the name used by the theme or plugin to remove the image size.

        add_action('init', 'remove_plugin_image_sizes');
        
        function remove_plugin_image_sizes() {
        	remove_image_size('image-size-name');
        }
        
        

        Another alternate could be using a plugin like ”Optimize Images Resizing”, which stops generating image sizes upon upload and only creates a new image size when you select that size to insert in the post.

        Administratör

  8. Yash Gautam says

    If i stop this from media settings, like set all to 0. is this make any effect on Responsive functionality ?

  9. Mohamed Abdel-Hady says

    Great article, but I have a question
    When I hired a developer to do my WP website, he sat the 3 default image sizes to some numbers which always made my gallery images to look pixelated when clicked on and enlarged inspite of using WP retina 2x plugin to make all my images look ”retina-quality”, so I sat those sizes to zeroes and tried re-uploading an image and baam, it looks super sharp, however, my subheader images never look as sharp or crisp …. DOES ANYONE KNOW WHY? IT’S DRIVING ME NUTS!!!

  10. Steve Woods says

    I am using Suffusion theme and beside the three native sizes of 200×200, 300×225, 400×300, I am also getting 96×96, 128×128, 128×72 and 480×360. That’s seven sizes!

    The problem is that all these different sizes may be seen by Google as duplication. That seems to hold water because only a small fraction of my images are being indexed.

    Is there a setting I am missing or plugin that can fix and clean this mess up?

    TIA

  11. Duncan says

    I want to be able to click on an image in my blog to open it as an enlarged version in a separate pop-up window. How?

  12. Amit Kr Sharma says

    Hello,
    i have a running image sharing website , usually we insert more then 20 images in a single post. I want to prevent WordPress from generating different image sizes for inserted images, except for the post featured image.

    For example If there’s 20 images in my post. I want WP to generate image sizes for the Featured image only, and for other inserted images i don’t want different sizes.
    Actually the problem is the limited storage space and the other problem is that with those useless image sizes the backup file has more size.

    How can I achieve this ?
    I appreciate your help.

  13. ITWEBMOB says

    But still one major issue , Stop use thumbnail native image
    I want Use cache image thumbnail inserted of native image, its create junk on web-space
    e.g If I upload one product its make 3-6 thumbnail image from original picture.

    How can I use Cache images system e.g. megento, prestashop, opencart with easy one click all cache clear option

    note: use spl folder location for store cache images not wp-content/2015/12/

  14. pavlo says

    Very helpful article, I found what generates 88×88 thumbnails in functions.php of my theme! thanks a lot!

  15. Marius says

    Thanks for the article. More than a year later it’s still useful! I just managed to change my theme to stop creating potentially thousands of variants of images I intend to have in WordPress galleries. However, what I did was
    (1) to comment out the add_image_size( ’square100’, 100, 100, true ) as suggested, and
    (2) to replace the parameters to the_post_thumbnail call (see WP Codex) with an array e g
    the_post_thumbnail(’square100’) became the_post_thumbnail( array(100,100)).
    This stopped the unnecessary creation of variants for every image loaded.
    To do this I had to override various functions and files in the theme by using a child theme, which is a whole subject on its own, and not to be attempted if you don’t have good knowledge of how child themes work!

  16. Nicolas says

    Hi do you happen to know how to unregister
    add_image_size
    set_post_thumbnail_size?

    While removing the line works i wouldn’t like to modify the theme and unregister on my child theme, so i don’t have to remember to do it again every time the theme updates.

    Thank you.

  17. Jay says

    I just read this and my theme and wordpress combined is generating 25 copies of each photo! I use a lot of photos on my site, the big question is how do we know which ones we can erase, i think three sizes is more then enough, but 25 sizes!

    Any thoughts WPBeginner!

  18. Jens Brogaard says

    Hi there, I think you’ve overlooked a way to decrease the number of generated image sizes;
    First, as you mention, get an overview of image settings in WP, theme and perhaps plugins – jot them down, px by px.
    Secondly, decide what is needed according to your visual needs. Often there’s small differences in e.g. thumbnail size but you can do with just one global size.
    Then lastly, align as much as possible, i.e. keep all the image settings but try to set as few variations as possible.
    I’n not in favor of messing around with the code since too often something will break down the road but this is just good practice of knowing what you want ;)

  19. greg taylor says

    Is there a computer–mac- windows-or chrome book, etc that lends itself to easier/better writing a wp blog—.com, not org? any overall ease of use for a newbie, like me?
    any thoughts on above appreciated.—greg —ww2–disabled vet

  20. Christian Zumbrunnen says

    There is a plugin called ”Regenarete Thumbnails” (and another one ”Force Regenerate Thumbnails”) which will resize existing images according to the new configuration. At least the second one promises to also delete the old resized images.

  21. Himanshu Goel says

    I want to keep the thumbnails and rest I want to ignore, so, I will change only other 2 options than Thumbnail and If this will work…

    Really, That will be helpful guys…!

  22. Christian says

    Thanks for the interesting article !

    You mention the ”uploads” folder but there is also the: /wp-content/uploads/et_temp folder which in my case is also full of copies of images. Can you shed some light on the purpose of this particular folder. I am using a ”Elegant Theme” called Envisioned.

    Thanks & Cheers,

    CF

    • WPBeginner Support says

      Seems like your theme or may be a plugin is responsible for adding images into this folder. Unfortunately, we can not specifically provide help with individual theme and plugin settings. You will need to contact your theme or plugin support and ask them how you can prevent this.

      Administratör

  23. Mike says

    FANTASTIC article. Now I just need to figure out how to delete the unneeded images that have already been generated, without deleting the ones I need.

  24. sachin says

    thank you so much for posting this. i have very tensed about disk space and inodes now i can feel some relief thank you very much….

  25. Karen H. says

    Thanks for another useful article. I’m just wondering whether removing the various image sizes would have an adverse effect on mobile/responsive WP sites. Don’t we need those sizes so the images can adjust to various screen sizes and orientations?

Lämna ett svar

Tack för att du väljer att lämna en kommentar. Tänk på att alla kommentarer modereras enligt våra policy för kommentarer, och din e-postadress kommer INTE att publiceras. Vänligen använd INTE nyckelord i namnfältet. Låt oss ha en personlig och meningsfull konversation.