Skip to content

Instantly share code, notes, and snippets.

@wycks
Last active December 16, 2020 01:48
Show Gist options
  • Select an option

  • Save wycks/4949242 to your computer and use it in GitHub Desktop.

Select an option

Save wycks/4949242 to your computer and use it in GitHub Desktop.

Revisions

  1. wycks renamed this gist Feb 21, 2013. 1 changed file with 0 additions and 0 deletions.
  2. wycks renamed this gist Feb 21, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. wycks revised this gist Feb 20, 2013. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,8 @@
    * If your theme has $content_width GLOBAL make sure and remove it
    */

    //example to add max size instead of using $content_width
    //example to add post-size instead of using $content_width and a max-size
    add_image_size( 'post-size', 600, 9999);
    add_image_size( 'max-size', 1600, 900, true);

    // over-ride image_size_names_choose
    @@ -22,7 +23,8 @@ function add_image_insert_override($size_names){
    $size_names = array(
    'thumbnail' => __('Thumbnail'),
    'medium' => __('Medium'),
    'large' => __('Large'),
    'large' => __('Large'),
    'post-size' => __('Post Size'),
    'max-size' => __('Max Size')
    //'full' => __('Full Size') bye bye
    );
  4. wycks revised this gist Feb 16, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@
    * If your theme has $content_width GLOBAL make sure and remove it
    */

    //example to add max size
    //example to add max size instead of using $content_width
    add_image_size( 'max-size', 1600, 900, true);

    // over-ride image_size_names_choose
  5. wycks revised this gist Feb 14, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,11 @@
    <?php

    /**
    * Have users/clients uploading massive files into posts and then complaining about load speed?
    *
    * This removes the ability to add the FULL image size into a post, it does not alter or delete the image
    * Add whataever extra image sizes to the insert dropdown in WordPress you create via add_image_size
    *
    * For now we have to do it this way to make the labels translatable, see tracrref below.
    * For now we have to do it this way to make the labels translatable, see trac ref below.
    *
    * If your theme has $content_width GLOBAL make sure and remove it
    */
  6. wycks revised this gist Feb 14, 2013. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,8 @@
    * Have users/clients uploading massive files into posts and then complaining about load speed?
    * This removes the ability to add the FULL image size into a post, it does not alter or delete the image
    * Add whataever extra image sizes to the insert dropdown in WordPress you create via add_image_size
    *
    * For now we have to do it this way to make the labels translatable, see tracrref below.
    *
    * If your theme has $content_width GLOBAL make sure and remove it
    */
  7. wycks revised this gist Feb 14, 2013. 1 changed file with 7 additions and 5 deletions.
    12 changes: 7 additions & 5 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,12 @@
    <?php

    // Have users/clients uploading massive files into posts and then complaining about load speed?
    //This removes the ability to add the FULL image size into a post, it does not alter or delete the image
    //Add whataever extra image sizes to the insert dropdown in WordPress you create via add_image_size

    // If your theme has $content_width GLOBAL make sure and remove it
    /**
    * Have users/clients uploading massive files into posts and then complaining about load speed?
    * This removes the ability to add the FULL image size into a post, it does not alter or delete the image
    * Add whataever extra image sizes to the insert dropdown in WordPress you create via add_image_size
    *
    * If your theme has $content_width GLOBAL make sure and remove it
    */

    //example to add max size
    add_image_size( 'max-size', 1600, 900, true);
  8. wycks revised this gist Feb 14, 2013. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,8 @@
    //This removes the ability to add the FULL image size into a post, it does not alter or delete the image
    //Add whataever extra image sizes to the insert dropdown in WordPress you create via add_image_size

    // If your theme has $content_width GLOBAL make sure and remove it

    //example to add max size
    add_image_size( 'max-size', 1600, 900, true);

  9. wycks revised this gist Feb 13, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -18,6 +18,7 @@ function add_image_insert_override($size_names){
    'medium' => __('Medium'),
    'large' => __('Large'),
    'max-size' => __('Max Size')
    //'full' => __('Full Size') bye bye
    );

    return $size_names;
  10. wycks revised this gist Feb 13, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ function add_image_insert_override($size_names){

    global $_wp_additional_image_sizes;

    //default array with hardcoded values fro add_image_size
    //default array with hardcoded values for add_image_size
    $size_names = array(
    'thumbnail' => __('Thumbnail'),
    'medium' => __('Medium'),
  11. wycks revised this gist Feb 13, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@
    add_image_size( 'max-size', 1600, 900, true);

    // over-ride image_size_names_choose
    function add_image_check_part2($size_names){
    function add_image_insert_override($size_names){

    global $_wp_additional_image_sizes;

    @@ -24,7 +24,7 @@ function add_image_check_part2($size_names){

    };

    add_filter('image_size_names_choose', 'add_image_check_part2' );
    add_filter('image_size_names_choose', 'add_image_insert_override' );


    // For referance
  12. wycks renamed this gist Feb 13, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  13. wycks created this gist Feb 13, 2013.
    33 changes: 33 additions & 0 deletions Prevent-Full-Size-Images
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    <?php

    // Have users/clients uploading massive files into posts and then complaining about load speed?
    //This removes the ability to add the FULL image size into a post, it does not alter or delete the image
    //Add whataever extra image sizes to the insert dropdown in WordPress you create via add_image_size

    //example to add max size
    add_image_size( 'max-size', 1600, 900, true);

    // over-ride image_size_names_choose
    function add_image_check_part2($size_names){

    global $_wp_additional_image_sizes;

    //default array with hardcoded values fro add_image_size
    $size_names = array(
    'thumbnail' => __('Thumbnail'),
    'medium' => __('Medium'),
    'large' => __('Large'),
    'max-size' => __('Max Size')
    );

    return $size_names;

    };

    add_filter('image_size_names_choose', 'add_image_check_part2' );


    // For referance
    //http://core.trac.wordpress.org/ticket/20663, http://core.trac.wordpress.org/ticket/19990

    ?>