Plugin Directory

Changeset 1163686


Ignore:
Timestamp:
05/19/2015 10:10:46 PM (11 years ago)
Author:
bendoh
Message:

Version 2.4.0 release

Location:
getty-images/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • getty-images/trunk/getty-images.css

    r1085627 r1163686  
    645645                width: 40px;
    646646            }
     647        .getty-embed-attachment-details {
     648            border-bottom: 1px solid #ddd;
     649            padding-bottom: 11px;
     650        }
    647651
    648652/* Top-level search form */
  • getty-images/trunk/getty-images.php

    r1091863 r1163686  
    7373        // Register shorcodes
    7474        add_action( 'init', array( $this, 'action_init' ) );
     75        // Handle shortcode alignment
     76        add_filter( 'embed_oembed_html', array( $this, 'align_embed' ), 10, 4 );
     77        // Add styles for alignment
     78        add_action( 'wp_head', array( $this, 'frontend_style' ) );
    7579    }
    7680
     
    8185    wp_oembed_add_provider( 'http://gty.im/*', 'http://embed.gettyimages.com/oembed' );
    8286  }
     87
     88    /**
     89     * Filter embed shortcode html
     90     * @param  string $html    html generated from embed shortcode
     91     * @param  string $url     original oembed URL
     92     * @param  array $attr     shortcode attributes
     93     * @param  integer $post_ID post id
     94     * @return string          modified or original html
     95     */
     96    function align_embed( $html, $url, $attr, $post_ID ) {
     97        // check that this is a getty embed
     98        if ( strpos( $url, 'http://gty.im/' ) === 0 ) {
     99            if ( isset( $attr['align'] ) && in_array( $attr['align'], array( 'left', 'center', 'right' ) ) ) {
     100                // container div must be displayed as block, rather than inline-block for center align
     101                if ( $attr['align'] == 'center' ) {
     102                    $html = preg_replace( '/^(<div[^>]*)inline-block/', '$1block', $html );
     103                }
     104                return str_replace( 'class="', 'class="' . esc_attr( 'align' . $attr['align'] ) . ' ', $html );
     105            }
     106        }
     107        return $html;
     108    }
     109
     110    /**
     111     * Print some frontend styles for getty embeds that are aligned
     112     */
     113    function frontend_style() {
     114        ?>
     115        <style>
     116        .getty.alignleft {
     117            margin-right: 5px;
     118        }
     119        .getty.alignright {
     120            margin-left: 5px;
     121        }
     122        </style>
     123        <?php
     124    }
    83125
    84126    // Convenience methods for adding 'message' data to standard
     
    163205                'nonce' => wp_create_nonce( 'getty-images' ),
    164206                'sizes' => $this->get_possible_image_sizes(),
     207                'embedSizes' => array(
     208                    'scale50' => array( 'scale' => 0.50, 'label' => __( 'Scaled 50%', 'getty-images' ) ),
     209                    'scale75' => array( 'scale' => 0.75, 'label' => __( 'Scaled 75%', 'getty-images' ) ),
     210                ),
    165211                'isWPcom' => $isWPcom,
    166212                'text' => array(
     
    226272                    'bestMatch' => __( "Best Match", 'getty-images' ),
    227273                    'newest' => __( "Newest", 'getty-images' ),
     274
     275                    'alignments' => array(
     276                        'none' => __( 'None', 'getty-images' ),
     277                        'left' => __( 'Left', 'getty-images' ),
     278                        'center' => __( 'Center', 'getty-images' ),
     279                        'right' => __( 'Right', 'getty-images' ),
     280                    ),
    228281                )
    229282            )
  • getty-images/trunk/getty-templates.php

    r1091863 r1163686  
    303303    </dd>
    304304    <# }
     305    // Specific for non logged in users (i.e. embedable images)
     306    if ( !gettyImages.isWPcom && !gettyImages.user.get('loggedIn') ) { #>
     307        <dt class="getty-image-caption"><?php esc_html_e( "Caption: ", 'getty-images' ); ?></dt>
     308        <dd class="getty-image-caption"><p class="description">{{ data.Caption }}</p></dd>
     309
     310        <dt class="getty-image-alt"><?php esc_html_e( "Alt Text: ", 'getty-images' ); ?></dt>
     311        <dd class="getty-image-alt"><p class="description">{{ data.Title }}</p></dd>
     312    <#
     313    }
    305314} #>
    306315</dl>
     
    358367
    359368<script type="text/html" id="tmpl-getty-display-settings">
    360 <# if(gettyImages.isWPcom || gettyImages.user.get('loggedIn')) { #>
    361369    <h3><?php esc_html_e( "Display Options", 'getty-images' ); ?></h3>
    362370
    363     <div class="setting align">
    364         <span><?php esc_html_e('Align'); ?></span>
    365         <select data-setting="align" data-user-setting="getty_align">
    366             <# selected = data.model.align == 'none' ? 'selected="selected"' : '' #>
    367             <option value="none" {{ selected }}>
    368                 <?php esc_html_e('None'); ?>
    369             </option>
    370             <# selected = data.model.align == 'left' ? 'selected="selected"' : '' #>
    371             <option value="left" {{ selected }}>
    372                 <?php esc_html_e('Left'); ?>
    373             </option>
    374             <# selected = data.model.align == 'center' ? 'selected="selected"' : '' #>
    375             <option value="center" {{ selected }}>
    376                 <?php esc_html_e('Center'); ?>
    377             </option>
    378             <# selected = data.model.align == 'right' ? 'selected="selected"' : '' #>
    379             <option value="right" {{ selected }}>
    380                 <?php esc_html_e('Right'); ?>
    381             </option>
    382         </select>
    383     </div>
    384 
    385     <label class="setting">
    386         <span><?php esc_html_e('Size'); ?></span>
    387         <select class="size" name="size" data-setting="size" data-user-setting="getty_imgsize">
    388         <# _.each(data.model.sizes, function(size, value) {
    389             var selected = data.model.size == size ? 'selected="selected"' : '';
    390             #>
    391             <option value="{{ value }}" {{{ selected }}}>{{ size.label }} &ndash; {{ parseInt(size.width) }} &times; {{ parseInt(size.height) }}</option>
    392         <# }); #>
    393         </select>
    394     </label>
    395 
    396     <label class="setting alt-text">
    397         <span><?php esc_html_e('Alt Text'); ?></span>
    398         <input type="text" data-setting="alt" value="{{ data.model.alt }}" data-user-setting="getty_alt" />
    399     </label>
    400 
    401     <label class="setting caption">
    402         <span><?php esc_html_e('Caption'); ?></span>
    403         <textarea data-setting="caption">{{ data.model.caption }}</textarea>
    404     </label>
    405 <# } else { #>
    406 <dl class="getty-image-details-list">
    407     <dt class="getty-image-caption"><?php esc_html_e( "Caption: ", 'getty-images' ); ?></dt>
    408     <dd class="getty-image-caption"><p class="description">{{ data.model.caption }}</p></dd>
    409 
    410     <dt class="getty-image-alt"><?php esc_html_e( "Alt Text: ", 'getty-images' ); ?></dt>
    411     <dd class="getty-image-alt"><p class="description">{{ data.model.alt }}</p></dd>
    412 </dl>
    413 <# } #>
     371    <div class="attachment-info">
     372        <div class="setting align">
     373            <span><?php esc_html_e( 'Align' ); ?></span>
     374            <select data-setting="align" data-user-setting="getty_align">
     375                <# _(gettyImages.text.alignments).each(function(text,value){ #>
     376                    <option value="{{ value }}" {{ ( data.model.align === value ) ? 'selected="selected"' : '' }}>
     377                        {{ text }}
     378                    </option>
     379                <# }); #>
     380            </select>
     381        </div>
     382
     383        <label class="setting">
     384            <span><?php esc_html_e('Size'); ?></span>
     385        <# if (data.model.downloadingSizes) { #>
     386            <em><?php esc_html_e( 'Downloading sizes...', 'getty-images' ); ?></em>
     387        <# } else { #>
     388            <select class="size" name="size" data-setting="size" data-user-setting="getty_imgsize">
     389            <# _.each(data.model.sizes, function(size, value) {
     390                var selected = data.model.size == size ? 'selected="selected"' : '';
     391                #>
     392                <option value="{{ value }}" {{{ selected }}}>{{ size.label }} &ndash; {{ parseInt(size.width) }} &times; {{ parseInt(size.height) }}</option>
     393            <# }); #>
     394            </select>
     395        <# } #>
     396        </label>
     397
     398    <# if(gettyImages.isWPcom || gettyImages.user.get('loggedIn')) { #>
     399        <label class="setting alt-text">
     400            <span><?php esc_html_e('Alt Text'); ?></span>
     401            <input type="text" data-setting="alt" value="{{ data.model.alt }}" data-user-setting="getty_alt" />
     402        </label>
     403
     404        <label class="setting caption">
     405            <span><?php esc_html_e('Caption'); ?></span>
     406            <textarea data-setting="caption">{{ data.model.caption }}</textarea>
     407        </label>
     408    <# } #>
     409    </div><!--// .attachment-info -->
    414410</script>
    415411
  • getty-images/trunk/js/getty-filters.js

    r923152 r1163686  
    6262                this.model.on('change', this.select, this);
    6363
    64         if(!getty.user.settings.get(this.prop))
    65           getty.user.settings.set(this.prop, this.value);
     64                if(typeof getty.user.settings.get(this.prop)==='undefined') {
     65                    getty.user.settings.set(this.prop, this.value);
     66                }
    6667
    6768                this.model.set(this.prop, getty.user.settings.get(this.prop));
  • getty-images/trunk/js/getty-images.js

    r1091863 r1163686  
    240240            }
    241241
     242            // Get display options from user
     243            var display = this.display(image)
     244                , align = display.get('align') || 'none'
     245                , sizeSlug = display.get('size') || 'full'
     246                , sizes = display.get('sizes')
     247                , size = sizes[sizeSlug]
     248            ;
     249
    242250            if(this.get('mode') == 'embed') {
    243251                //Build the Embed code and insert it
    244252                embed_code = 'http://gty.im/' + image.get('ImageId');
    245253
     254                var attrs = {};
     255                if ( align != 'none' ) {
     256                    attrs.align = align;
     257                }
     258
     259                if ( sizeSlug != 'full' ) {
     260                    attrs.width = size.width;
     261                    attrs.height = size.height;
     262                }
     263
     264                if ( _.keys(attrs).length ) {
     265                    embed_code = wp.shortcode.string({
     266                        tag: 'embed',
     267                        content: embed_code,
     268                        attrs: attrs,
     269                    });
     270                }
     271
    246272                wp.media.editor.insert("\n" + embed_code + "\n");
    247273            } else {
    248274
    249                 // Get display options from user
    250                 var display = this.display(image);
    251 
    252                 var align = display.get('align') || 'none';
    253275                var alt = display.get('alt');
    254276                var caption = display.get('caption');
    255 
    256                 var sizeSlug = display.get('size');
    257                 var sizes = display.get('sizes');
    258                 var size = sizes[sizeSlug];
    259277
    260278                if(!size) {
  • getty-images/trunk/js/getty-models.js

    r1091863 r1163686  
    10671067            }, this);
    10681068            this.wpAttachment = this.attachment.get('attachment');
    1069             this.set('caption', this.attachment.get('Caption'));
    1070             this.set('alt', this.attachment.get('Title'));
    10711069            this.set('sizes', _.clone(getty.sizes));
     1070            //set defaults for embeds
     1071            if ( !gettyImages.isWPcom && !gettyImages.user.get('loggedIn') ) {
     1072                this.set({
     1073                    align: 'none',
     1074                    size: 'full',
     1075                });
     1076            }
    10721077            this.fetch();
    10731078        },
     
    10971102
    10981103                $(this.image).on('load', this.loadImage());
     1104                this.set('downloadingSizes',true);
    10991105                this.image.src = url;
    11001106            }
     
    11111117
    11121118                // Constrain image to image sizes
    1113                 _.each(gettyImages.sizes, function(size, slug) {
    1114                     var cr = size.width / size.height;
    1115                     var s = { label: size.label };
    1116 
    1117                     s.url = this.src;
    1118 
    1119                     if(ar > cr) {
    1120                         // Constrain to width
    1121                         s.width = parseInt(size.width);
    1122                         s.height = parseInt(size.width / ar);
    1123                     }
    1124                     else {
    1125                         // Constrain to height (or square!)
    1126                         s.width = parseInt(ar * size.height);
    1127                         s.height = parseInt(size.height);
    1128                     }
    1129 
    1130                     sizes[slug] = s;
    1131                 }, this);
     1119                if ( gettyImages.isWPcom || gettyImages.user.get('loggedIn') ) {
     1120                    _.each(gettyImages.sizes, function(size, slug) {
     1121                        var cr = size.width / size.height;
     1122                        var s = { label: size.label };
     1123
     1124                        s.url = this.src;
     1125
     1126                        if(ar > cr) {
     1127                            // Constrain to width
     1128                            s.width = parseInt(size.width);
     1129                            s.height = parseInt(size.width / ar);
     1130                        }
     1131                        else {
     1132                            // Constrain to height (or square!)
     1133                            s.width = parseInt(ar * size.height);
     1134                            s.height = parseInt(size.height);
     1135                        }
     1136
     1137                        sizes[slug] = s;
     1138                    }, this);
     1139                } else {
     1140                    _.each(gettyImages.embedSizes, function(size, slug) {
     1141                        sizes[slug] = {
     1142                            label: size.label,
     1143                            width: parseInt(size.scale * this.width),
     1144                            height: parseInt(size.scale * this.height),
     1145                        };
     1146                    }, this);
     1147                }
    11321148
    11331149                sizes.full = {
     
    11381154                }
    11391155
     1156                self.unset('downloadingSizes');
    11401157                self.set('sizes', sizes);
    11411158            }
  • getty-images/trunk/js/getty-views.js

    r1091863 r1163686  
    289289                var displayOptions = {
    290290                    model: this.model.display(attachment),
    291                     priority: 200,
     291                    // for non-logged in users, put the display options higher
     292                    priority: (!gettyImages.isWPcom && !gettyImages.user.get('loggedIn')) ? 50 : 200,
    292293                    userSettings: true
    293294                };
Note: See TracChangeset for help on using the changeset viewer.