Skip to content

Commit

Permalink
fix: image url replacement on custom WordPress directory structure, f…
Browse files Browse the repository at this point in the history
…ixes #79, thanks @hackles for reporting
  • Loading branch information
selul committed Mar 11, 2019
1 parent 9dfff11 commit dafb81e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions inc/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private function request( $path, $method = 'GET', $params = array(), $extra_head
// Grab the url to which we'll be making the request.
$url = $this->api_root;
$headers = array(
'Optml-Site' => get_site_url(),
'Optml-Site' => get_home_url(),
);
if ( ! empty( $this->api_key ) ) {
$headers['Authorization'] = 'Bearer ' . $this->api_key;
Expand Down Expand Up @@ -139,7 +139,7 @@ public function create_account( $email ) {
'POST',
array(
'email' => $email,
'site' => get_site_url(),
'site' => get_home_url(),
)
);
}
Expand Down
6 changes: 3 additions & 3 deletions inc/app_replacer.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public function set_properties() {
'directory' => $upload_data['basedir'],
);
$this->upload_resource['url_length'] = strlen( $this->upload_resource['url'] );
$this->upload_resource['content_path'] = str_replace( get_site_url(), '', content_url() );
$this->upload_resource['content_path'] = str_replace( get_home_url(), '', content_url() );

$service_data = $this->settings->get( 'service_data' );

Expand All @@ -246,12 +246,12 @@ public function set_properties() {
$this->site_mappings['//i2.wp.com/'] = '//';

if ( defined( 'OPTML_SITE_MIRROR' ) && constant( 'OPTML_SITE_MIRROR' ) ) {
$this->site_mappings[ rtrim( get_site_url(), '/' ) ] = rtrim( constant( 'OPTML_SITE_MIRROR' ), '/' );
$this->site_mappings[ rtrim( get_home_url(), '/' ) ] = rtrim( constant( 'OPTML_SITE_MIRROR' ), '/' );
}

$this->possible_sources = $this->extract_domain_from_urls(
array_merge(
array( get_site_url() ),
array( get_home_url() ),
array_values( $this->site_mappings ),
array_keys( $this->site_mappings )
)
Expand Down
2 changes: 1 addition & 1 deletion inc/tag_replacer.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function process_image_tags( $content, $images = array() ) {

$src = $tmp = $is_slashed ? stripslashes( $images['img_url'][ $index ] ) : $images['img_url'][ $index ];

$src = $tmp = strpos( $src, $this->upload_resource['content_path'] ) === 0 ? untrailingslashit( get_site_url() ) . $src : $src;
$src = $tmp = strpos( $src, $this->upload_resource['content_path'] ) === 0 ? untrailingslashit( get_home_url() ) . $src : $src;

if ( apply_filters( 'optml_ignore_image_link', false, $src ) ||
false !== strpos( $src, Optml_Config::$service_url ) ||
Expand Down

0 comments on commit dafb81e

Please sign in to comment.