Calling all Wordpress experts - RESOLVED

ecoleman

Suspended / Banned
Messages
6,992
Name
Elliott
Edit My Images
No
I have just setup a website to show off some of my images. It's a Wordpress site and I've purchased a theme which has installed fine.

The theme has some functions in a file called thumbnails.php that generates a bunch of image sizes when you upload an image. One size for full screen gallery, smaller ones for thumbnails etc.
The maximum file size it creates it 2048px which I want to increase to 2560px as the 2048px images are upscaled in larger monitors reducing the quality.

This function resides in wp-content/themes/border/inc/includes/functions/thumbnails.php and the function is

Code:
function wpgrade_custom_thumbnails (){
  
    // Add theme support for Featured Images
    add_theme_support( 'post-thumbnails' );

    /*
     * MAXIMUM SIZE
     * Maximum Full Image Size
     * - Sliders
     * - Lightbox
     */
    add_image_size('full-size', 2048);     <---- I WANT TO CHANGE THIS TO 2560

    /*
     * MEDIUM SIZE
     * - Split Article
     * - Tablet Sliders
     */
    add_image_size('medium-size', 1024);

    /*
     * SMALL SIZE
     * - Masonry Grid
     * - Mobile Sliders
     */
    add_image_size('small-size', 400);

    /*
     * SQUARE
     * - Gallery Grid
     * - Portfolio & Gallery Archive
     */
    add_image_size('square', 400, 400, true);



    // Classic blog
    add_image_size('post-big', 840);

    // Border blog
    add_image_size('post-medium', 265, 328, true);

    // Split blog
    add_image_size('post-medium', 265, 328, true);

}

If I change this to 2560 and save it and upload a new image the max sized is correctly sized to 2560 as expected, but I am aware that if the theme is updated this will revert back to 2048.

I've read a bit about child themes and the function.php file, but being a Wordpress newbie I don't really understand what I need to do.

How do I make this change so that future updates to the theme will not revert the file size back to 2048px?

Thanks in Advance.
 
Last edited:
Not able to directly help with your issue other than to say you are on the right lines and make sure you do get the child theme thing sorted!

I couldn't get my head round it when I set up mine and convinced myself it wasn't that big a deal. Boy do I regret that every time I get a theme update now!
 
Creating a child-theme is fairly easy.

This guide explains how to do it:
https://managewp.com/how-to-create-a-child-theme

Essentially, it's create a folder for the childtheme. Create a css file with some meta data in it as comments. And then add an import directive to the CSS file pointing to the parent themes CSS file.

At this point, test the child theme. If it's working, begin making your modifications.
 
Thanks afasoas.

Ive got as far as creating a child theme with CSS file and functions.php and that's all working fine.

Now I'm just trying to figure out how to overwrite their function with my new one. I've tried a few methods found online but so far I'm just getting errors about duplicate functions.
 
You've probably checked but what about the current max theme width, if its less than 2560 will it not restrict the full image
 
What solved it?
It might help someone else with a similar problem.
 
I created a child theme and added the following code into the functions.php file.

Code:
add_action('after_setup_theme', 'new_full_size_image', 15 );
function new_full_size_image() {
    add_image_size ('full-size', 2560);
}

It's a custom function that has a load priotity of 15 (default priority is 10) which means it loads after the default function provided by the parent theme. This functions overwrites the add_image_size ('full-size', 2048) created by the parent theme.

It took a bit of reading various sites. Most aren't that clear and appear to assume you understand the workings of wordpress. Whilst I'm fairly good with PHP, I've never worked with wordpress before.
 
Last edited:
Back
Top