Plugin Directory

Changeset 1910099


Ignore:
Timestamp:
07/17/2018 01:39:54 AM (8 years ago)
Author:
alexmacarthur
Message:

Update to v3.3.1 to address image meta tag issues.

Location:
complete-open-graph
Files:
34 added
4 edited

Legend:

Unmodified
Added
Removed
  • complete-open-graph/trunk/complete-open-graph.php

    r1901559 r1910099  
    33* Plugin Name: Complete Open Graph
    44* Description: Simple, comprehensive, highly customizable Open Graph management.
    5 * Version: 3.3.0
     5* Version: 3.3.1
    66* Author: Alex MacArthur
    77* Author URI: https://macarthur.me
  • complete-open-graph/trunk/composer.json

    r1901559 r1910099  
    55  "minimum-stability": "stable",
    66  "license": "GPL-2.0",
    7   "version": "3.3.0",
     7  "version": "3.3.1",
    88  "authors": [
    99    {
     
    1616  "support" : {
    1717    "issues": "https://wordpress.org/support/plugin/complete-open-graph",
    18     "source": "https://downloads.wordpress.org/plugin/complete-open-graph.3.3.0.zip"
     18    "source": "https://downloads.wordpress.org/plugin/complete-open-graph.3.3.1.zip"
    1919    },
    2020    "autoload-dev": {
  • complete-open-graph/trunk/readme.txt

    r1901559 r1910099  
    55Tags: open graph, seo, open graph protocol, twitter, facebook, social media, google plus
    66Requires at least: 3.9
    7 Tested up to: 4.9.6
    8 Stable tag: 3.3.0
     7Tested up to: 4.9.7
     8Stable tag: 3.3.1
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    287287* Add filter to disable Open Graph tags per page.
    288288
     289= 3.3.1 =
     290* Improve the logic (and respective efficiency) of determining how image meta tags are generated.
     291
    289292== Feedback ==
    290293
  • complete-open-graph/trunk/src/Filters.php

    r1901559 r1910099  
    2626  public function attach_image_dimensions($value, $field_name) {
    2727
    28     $width = '';
    29         $height = '';
    30 
     28        //-- This is probably a URL from an older version of the plugin. Just return it.
    3129        if(!is_numeric($value)) return $value;
    3230
    33         //-- Ensure this is actually an integer.
    34         $value = intval($value);
     31        $imageSizes = array(
     32            'complete_open_graph',
     33            'large',
     34            'medium_large',
     35            'medium',
     36            'full'
     37        );
    3538
    36         //-- If this attachment doesn't actually exist or isn't an image, just get out of here.
    37         if(!wp_attachment_is_image($value)) return '';
     39        $data = false;
     40        $attachmentMeta = wp_get_attachment_metadata($value);
     41        $sizes = isset($attachmentMeta['sizes']) ? $attachmentMeta['sizes'] : array();
    3842
    39         $attachment_meta = wp_get_attachment_metadata($value);
     43        //-- The 'full' size isn't included by default.
     44        $sizes['full'] = true;
    4045
    41         //-- For some weird reason, some images might not have a size key? It's apparently happened...
    42         if(empty($attachment_meta) || !isset($attachment_meta['sizes'])) return '';
     46        //-- Loop over each image size. Serves as a fallback mechanism if it doesn't exist at the ideal size.
     47        foreach($imageSizes as $size) {
    4348
    44         if(array_key_exists('complete_open_graph', $attachment_meta['sizes'])) {
    45             $meta = wp_get_attachment_image_src($value, 'complete_open_graph');
    46         } elseif(array_key_exists('large', $attachment_meta['sizes'])) {
    47             $meta = wp_get_attachment_image_src($value, 'large');
    48         } else {
    49             $meta = false;
     49            //-- We have an image!
     50            if(array_key_exists($size, $sizes)) {
     51                $data = wp_get_attachment_image_src($value, $size);
     52                break;
     53            }
    5054        }
    5155
    52         //-- If, for some reason, no image is returned, just get out of here.
    53         if(!($meta)) return '';
     56        //-- If, for some reason, no image is returned, exit. Should NEVER actually happen, but you know... #wordpress.
     57        if(empty($data)) return '';
    5458
    55         $value = $meta[0];
    56         $width = $meta[1];
    57         $height = $meta[2];
     59        $value = $data[0];
     60        $width = $data[1];
     61        $height = $data[2];
    5862
    5963    //-- Set image sizes.
Note: See TracChangeset for help on using the changeset viewer.