Inventory_Presser_Plugin::change_attachment_urls( string $url, int $post_id = null )
change_attachment_urls
Contents
Description Description
Adds a querystring to vehicle attachment photo URLs to fight caching.
Parameters Parameters
- $url
-
(string) (Required)
- $post_id
-
(int) (Optional)
Default value: null
Return Return
(string) The changed URL
Source Source
File: inventory-presser.php
public function change_attachment_urls( $url, $post_id = null ) { if( empty( $post_id ) ) { $post_id = attachment_url_to_postid( $url ); } if( INVP::POST_TYPE != get_post_type( wp_get_post_parent_id( $post_id ) ) ) { return $url; } //This could be controversial switch( substr( $url, -4 ) ) { case 'jpeg': case '.jpg': case '.png': break; default: return $url; } //Add a querystring that contains this photo's hash $hash = INVP::get_meta( 'hash', $post_id ); if( empty( $hash ) ) { return $url; } return $url . '?' . $hash; }
Expand full source code Collapse full source code View on Github