GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Business Wordpress help please! (https://gfy.com/showthread.php?t=1257715)

rogueteens 04-15-2017 08:39 AM

Wordpress help please!
 
Two questions ....

1) What's the best wordpress stats plug-in at the moment? I'm mostly after low server load with this plugin.

2) Is there a way for a wordpress install to check on uploaded images and refuse ones that are below a sertain size?

Cheers.

fris 04-15-2017 10:41 AM

1. https://en-ca.wordpress.org/plugins/...for-wordpress/

they have a pro version too.

2. you can use filters to limit the size, depends if you want dimensions, or filesize

which is it you want for #2?

fris 04-15-2017 10:45 AM

here is both methods

Code:

add_filter('wp_handle_upload_prefilter','_limit_image_dimensions');

function _limit_image_dimensions( $file ) {
    $image = getimagesize($file['tmp_name']);

    $minimum = array(
        'width' => '400',
        'height' => '400'
    );

    $maximum = array(
        'width' => '2000',
        'height' => '2000'
    );
    $image_width = $image[0];
    $image_height = $image[1];

    $too_small = "Image dimensions are too small. Minimum size is {$minimum['width']} by {$minimum['height']} pixels. Uploaded image is $image_width by $image_height pixels.";
    $too_large = "Image dimensions are too large. Maximum size is {$maximum['width']} by {$maximum['height']} pixels. Uploaded image is $image_width by $image_height pixels.";

    if ( $image_width < $minimum['width'] || $image_height < $minimum['height'] ) {
        $file['error'] = $too_small;
        return $file;
    }
    elseif ( $image_width > $maximum['width'] || $image_height > $maximum['height'] ) {
        $file['error'] = $too_large;
        return $file;
    }
    else
        return $file;
}

function _limit_image_size($file) {

    $image_size = $file['size']/1024;

    $limit = 200; // size in kb

    $is_image = strpos($file['type'], 'image');

    if ( ( $image_size > $limit ) && ($is_image !== false) )
          $file['error'] = 'Your picture is too large. It has to be smaller than '. $limit .'KB';

          return $file;

}
add_filter('wp_handle_upload_prefilter', '_limit_image_size');


rogueteens 04-15-2017 10:48 AM

cheers, I've already installed that google analytics for wordpress, I saw how many d/ls it had and thought it worth a try.

the code, which file should it go in?

fris 04-15-2017 11:23 AM

your themes functions.php file

rogueteens 04-15-2017 02:05 PM

Thanks, unfortunately, it didn't work. I've a feeling that there is already code in the functions code that does this but is set very low, maybe but php is dutch to me.

fris 04-15-2017 05:07 PM

Quote:

Originally Posted by rogueteens (Post 21707290)
Thanks, unfortunately, it didn't work. I've a feeling that there is already code in the functions code that does this but is set very low, maybe but php is dutch to me.

if you can send me the theme i can assist.

zip it up and email me it.

NatalieK 04-15-2017 07:55 PM

bump for help on WP, maybe BabeTerminal can help, he´s not much good for anything, but who knows...

:2 cents:

rogueteens 04-16-2017 02:54 AM

Quote:

Originally Posted by fris (Post 21707455)
if you can send me the theme i can assist.

zip it up and email me it.

mail sent, many thanks :)


All times are GMT -7. The time now is 10:05 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123