Skip to main content
added 455 characters in body
Source Link
Ksenia
  • 49
  • 1
  • 8

I use the following code to get image sizes:

public function getImageSizes(){
        global $_wp_additional_image_sizes;
        $sizes = array();
        foreach(get_intermediate_image_sizes() as $s){
            $sizes[$s] = array(0, 0);
            if( in_array( $s, array( 'thumbnail', 'medium', 'large' ) ) ){
                $sizes[$s][0] = get_option( $s . '_size_w' );
                $sizes[$s][1] = get_option( $s . '_size_h' );
            } else {
                if ( isset( $_wp_additional_image_sizes ) && isset( $_wp_additional_image_sizes[ $s ] ) )
                    $sizes[$s] = array( $_wp_additional_image_sizes[$s]['width'], $_wp_additional_image_sizes[$s]['height'] );
            }
        }
        return $sizes;
    }

The result is a select with image sizes, something like this:

<option value="thumbnail">Thumbnail</option>
<option value="medium">Medium</option>
<option value="large">Large</option>
<option value="tribe_image_widget_custom" selected='selected'>Custom</option>

The question is how to translate sizes (Thumbnail, Medium, Large and Custom)? By default the sizes are in English, I need them to be another language (I use CodeStyling Localization plugin for it).

Thank you!

P.S.: to biuld a select I use this code:

<select class="widefat" id="<?php echo $this->get_field_id('size'); ?>" name="<?php echo $this->get_field_name('size'); ?>">
    <?php foreach ($this->getImageSizes() as $name => $atts): ?>
        <option value="<?php echo $name ?>"<?php echo ($name==$size?' selected':'') ?>><?php echo ucwords($name) . ' ('. implode( 'x', $atts ). ')' ?></option>
    <?php endforeach ?>
</select>

I use the following code to get image sizes:

public function getImageSizes(){
        global $_wp_additional_image_sizes;
        $sizes = array();
        foreach(get_intermediate_image_sizes() as $s){
            $sizes[$s] = array(0, 0);
            if( in_array( $s, array( 'thumbnail', 'medium', 'large' ) ) ){
                $sizes[$s][0] = get_option( $s . '_size_w' );
                $sizes[$s][1] = get_option( $s . '_size_h' );
            } else {
                if ( isset( $_wp_additional_image_sizes ) && isset( $_wp_additional_image_sizes[ $s ] ) )
                    $sizes[$s] = array( $_wp_additional_image_sizes[$s]['width'], $_wp_additional_image_sizes[$s]['height'] );
            }
        }
        return $sizes;
    }

The result is a select with image sizes, something like this:

<option value="thumbnail">Thumbnail</option>
<option value="medium">Medium</option>
<option value="large">Large</option>
<option value="tribe_image_widget_custom" selected='selected'>Custom</option>

The question is how to translate sizes (Thumbnail, Medium, Large and Custom)? By default the sizes are in English, I need them to be another language (I use CodeStyling Localization plugin for it).

Thank you!

I use the following code to get image sizes:

public function getImageSizes(){
        global $_wp_additional_image_sizes;
        $sizes = array();
        foreach(get_intermediate_image_sizes() as $s){
            $sizes[$s] = array(0, 0);
            if( in_array( $s, array( 'thumbnail', 'medium', 'large' ) ) ){
                $sizes[$s][0] = get_option( $s . '_size_w' );
                $sizes[$s][1] = get_option( $s . '_size_h' );
            } else {
                if ( isset( $_wp_additional_image_sizes ) && isset( $_wp_additional_image_sizes[ $s ] ) )
                    $sizes[$s] = array( $_wp_additional_image_sizes[$s]['width'], $_wp_additional_image_sizes[$s]['height'] );
            }
        }
        return $sizes;
    }

The result is a select with image sizes, something like this:

<option value="thumbnail">Thumbnail</option>
<option value="medium">Medium</option>
<option value="large">Large</option>
<option value="tribe_image_widget_custom" selected='selected'>Custom</option>

The question is how to translate sizes (Thumbnail, Medium, Large and Custom)? By default the sizes are in English, I need them to be another language (I use CodeStyling Localization plugin for it).

Thank you!

P.S.: to biuld a select I use this code:

<select class="widefat" id="<?php echo $this->get_field_id('size'); ?>" name="<?php echo $this->get_field_name('size'); ?>">
    <?php foreach ($this->getImageSizes() as $name => $atts): ?>
        <option value="<?php echo $name ?>"<?php echo ($name==$size?' selected':'') ?>><?php echo ucwords($name) . ' ('. implode( 'x', $atts ). ')' ?></option>
    <?php endforeach ?>
</select>
Tweeted twitter.com/#!/StackWordPress/status/490196295425196032
Source Link
Ksenia
  • 49
  • 1
  • 8

How to translate get_intermediate_image_sizes?

I use the following code to get image sizes:

public function getImageSizes(){
        global $_wp_additional_image_sizes;
        $sizes = array();
        foreach(get_intermediate_image_sizes() as $s){
            $sizes[$s] = array(0, 0);
            if( in_array( $s, array( 'thumbnail', 'medium', 'large' ) ) ){
                $sizes[$s][0] = get_option( $s . '_size_w' );
                $sizes[$s][1] = get_option( $s . '_size_h' );
            } else {
                if ( isset( $_wp_additional_image_sizes ) && isset( $_wp_additional_image_sizes[ $s ] ) )
                    $sizes[$s] = array( $_wp_additional_image_sizes[$s]['width'], $_wp_additional_image_sizes[$s]['height'] );
            }
        }
        return $sizes;
    }

The result is a select with image sizes, something like this:

<option value="thumbnail">Thumbnail</option>
<option value="medium">Medium</option>
<option value="large">Large</option>
<option value="tribe_image_widget_custom" selected='selected'>Custom</option>

The question is how to translate sizes (Thumbnail, Medium, Large and Custom)? By default the sizes are in English, I need them to be another language (I use CodeStyling Localization plugin for it).

Thank you!