Gallery Custom Links - Version 1.2.5

Version Description

  • Fix: Avoid errors in the admin.
  • Fix: Add another way to resolve the image ID if none found (https://wordpress.org/support/topic/issue-with-page-links-on-images/), let's see how it goes.
Download this release

Release Info

Developer TigrouMeow
Plugin Icon 128x128 Gallery Custom Links
Version 1.2.5
Comparing to
See all releases

Code changes from version 1.2.4 to 1.2.5

Files changed (3) hide show
  1. gallery-custom-links.php +2 -2
  2. mgcl_core.php +13 -1
  3. readme.txt +3 -2
gallery-custom-links.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Gallery Custom Links
4
  Plugin URI: https://meowapps.com
5
  Description: Gallery Custom Links allows you to link images from galleries to a specified URL. Tested with WordPress Gallery, Gutenberg, the Meow Gallery and others.
6
- Version: 1.2.4
7
  Author: Jordy Meow
8
  Author URI: https://meowapps.com
9
  Text Domain: gallery-custom-links
@@ -23,7 +23,7 @@ if ( class_exists( 'Meow_Gallery_Custom_Links' ) ) {
23
  }
24
 
25
  global $mgcl_version;
26
- $mgcl_version = '1.2.4';
27
 
28
  include "mgcl_admin.php";
29
  $mgcl_admin = new Meow_Gallery_Custom_Links_Admin( 'mgcl', __FILE__, 'gallery-custom-links' );
3
  Plugin Name: Gallery Custom Links
4
  Plugin URI: https://meowapps.com
5
  Description: Gallery Custom Links allows you to link images from galleries to a specified URL. Tested with WordPress Gallery, Gutenberg, the Meow Gallery and others.
6
+ Version: 1.2.5
7
  Author: Jordy Meow
8
  Author URI: https://meowapps.com
9
  Text Domain: gallery-custom-links
23
  }
24
 
25
  global $mgcl_version;
26
+ $mgcl_version = '1.2.5';
27
 
28
  include "mgcl_admin.php";
29
  $mgcl_admin = new Meow_Gallery_Custom_Links_Admin( 'mgcl', __FILE__, 'gallery-custom-links' );
mgcl_core.php CHANGED
@@ -80,8 +80,20 @@ class Meow_Gallery_Custom_Links
80
  $pattern = '/[_-]\d+x\d+(?=\.[a-z]{3,4}$)/';
81
  $url = preg_replace( $pattern, '', $url );
82
  $url = $this->get_pathinfo_from_image_src( $url );
83
- $query = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE guid LIKE '%s'", '%' . $url . '%' );
 
84
  $attachment = $wpdb->get_col( $query );
 
 
 
 
 
 
 
 
 
 
 
85
  return empty( $attachment ) ? null : $attachment[0];
86
  }
87
 
80
  $pattern = '/[_-]\d+x\d+(?=\.[a-z]{3,4}$)/';
81
  $url = preg_replace( $pattern, '', $url );
82
  $url = $this->get_pathinfo_from_image_src( $url );
83
+ $urlLike = '%' . $url . '%';
84
+ $query = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE guid LIKE '%s'", $urlLike );
85
  $attachment = $wpdb->get_col( $query );
86
+
87
+ // Code proposed by @wizardcoder
88
+ // https://wordpress.org/support/topic/issue-with-page-links-on-images/
89
+ if ( empty( $attachment ) ) {
90
+ $query = $wpdb->prepare(
91
+ "SELECT post_id FROM $wpdb->postmeta WHERE meta_value LIKE '%s' AND meta_key = '_wp_attached_file'",
92
+ $urlLike
93
+ );
94
+ $attachment = $wpdb->get_col( $query );
95
+ }
96
+
97
  return empty( $attachment ) ? null : $attachment[0];
98
  }
99
 
readme.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: https://commerce.coinbase.com/checkout/d047546a-77a8-41c8-9ea9-4a95
5
  Requires at least: 5.0
6
  Tested up to: 5.3
7
  Requires PHP: 7.0
8
- Stable tag: 1.2.4
9
 
10
  Gallery Custom Links allows you to link images from galleries to a specified URL. Tested with WordPress Gallery, Gutenberg, the Meow Gallery and others.
11
 
@@ -42,8 +42,9 @@ Replace all the files. Nothing else to do.
42
 
43
  == Changelog ==
44
 
45
- = 1.2.4 =
46
  * Fix: Avoid errors in the admin.
 
47
 
48
  = 1.2.3 =
49
  * Add: Label for CTA buttons.
5
  Requires at least: 5.0
6
  Tested up to: 5.3
7
  Requires PHP: 7.0
8
+ Stable tag: 1.2.5
9
 
10
  Gallery Custom Links allows you to link images from galleries to a specified URL. Tested with WordPress Gallery, Gutenberg, the Meow Gallery and others.
11
 
42
 
43
  == Changelog ==
44
 
45
+ = 1.2.5 =
46
  * Fix: Avoid errors in the admin.
47
+ * Fix: Add another way to resolve the image ID if none found (https://wordpress.org/support/topic/issue-with-page-links-on-images/), let's see how it goes.
48
 
49
  = 1.2.3 =
50
  * Add: Label for CTA buttons.