Skip to content

Commit

Permalink
fix: Use images subdomain for images (#9009)
Browse files Browse the repository at this point in the history
  • Loading branch information
hangy committed Sep 19, 2023
1 parent f05ede9 commit 273676f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
8 changes: 4 additions & 4 deletions cgi/product_image.pl
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@
my $display_image_url;
my $full_image_url;
if ($id =~ /^\d+$/) {
$display_image_url = "/images/products/$path/$id.$display_size.jpg";
$full_image_url = "/images/products/$path/$id.jpg";
$display_image_url = "$images_subdomain/images/products/$path/$id.$display_size.jpg";
$full_image_url = "$images_subdomain/images/products/$path/$id.jpg";
}
else {
$display_image_url = "/images/products/$path/$id.$rev.$display_size.jpg";
$full_image_url = "/images/products/$path/$id.$product_ref->{images}{$id}{rev}.full.jpg";
$display_image_url = "$images_subdomain/images/products/$path/$id.$rev.$display_size.jpg";
$full_image_url = "$images_subdomain/images/products/$path/$id.$product_ref->{images}{$id}{rev}.full.jpg";
}

my $photographer = $product_ref->{images}{$id}{uploader};
Expand Down
2 changes: 1 addition & 1 deletion lib/ProductOpener/Display.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7484,7 +7484,7 @@ HTML

if (-e "$www_root/images/products/$path/$filename.full.json") {
$html .= <<HTML
<a href="/images/products/$path/$filename.full.json">OCR result</a>
<a href="$images_subdomain/images/products/$path/$filename.full.json">OCR result</a>
HTML
;
}
Expand Down
15 changes: 8 additions & 7 deletions lib/ProductOpener/Images.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1808,29 +1808,30 @@ sub display_image ($product_ref, $id_lc, $size) {
# add srcset with 2x image only if the 2x image exists
my $srcset = '';
if (defined $product_ref->{images}{$id}{sizes}{$display_size}) {
$srcset = "srcset=\"/images/products/$path/$id.$rev.$display_size.jpg 2x\"";
$srcset = "srcset=\"$images_subdomain/images/products/$path/$id.$rev.$display_size.jpg 2x\"";
}

$html .= <<HTML
<img class="hide-for-xlarge-up" src="/images/products/$path/$id.$rev.$size.jpg" $srcset width="$product_ref->{images}{$id}{sizes}{$size}{w}" height="$product_ref->{images}{$id}{sizes}{$size}{h}" alt="$alt" itemprop="thumbnail" loading="lazy" />
<img class="hide-for-xlarge-up" src="$images_subdomain/images/products/$path/$id.$rev.$size.jpg" $srcset width="$product_ref->{images}{$id}{sizes}{$size}{w}" height="$product_ref->{images}{$id}{sizes}{$size}{h}" alt="$alt" itemprop="thumbnail" loading="lazy" />
HTML
;

$srcset = '';
if (defined $product_ref->{images}{$id}{sizes}{$zoom_size}) {
$srcset = "srcset=\"/images/products/$path/$id.$rev.$zoom_size.jpg 2x\"";
$srcset = "srcset=\"$images_subdomain/images/products/$path/$id.$rev.$zoom_size.jpg 2x\"";
}

$html .= <<HTML
<img class="show-for-xlarge-up" src="/images/products/$path/$id.$rev.$display_size.jpg" $srcset width="$product_ref->{images}{$id}{sizes}{$display_size}{w}" height="$product_ref->{images}{$id}{sizes}{$display_size}{h}" alt="$alt" itemprop="thumbnail" loading="lazy" />
<img class="show-for-xlarge-up" src="$images_subdomain/images/products/$path/$id.$rev.$display_size.jpg" $srcset width="$product_ref->{images}{$id}{sizes}{$display_size}{w}" height="$product_ref->{images}{$id}{sizes}{$display_size}{h}" alt="$alt" itemprop="thumbnail" loading="lazy" />
HTML
;

if (($size eq $small_size) and (defined $product_ref->{images}{$id}{sizes}{$display_size})) {

my $title = lang($id . '_alt');

my $full_image_url = "/images/products/$path/$id.$product_ref->{images}{$id}{rev}.full.jpg";
my $full_image_url
= "$images_subdomain/images/products/$path/$id.$product_ref->{images}{$id}{rev}.full.jpg";
my $representative_of_page = '';
if ($id eq 'front') {
$representative_of_page = 'true';
Expand Down Expand Up @@ -1863,7 +1864,7 @@ HTML
else {
# jquery mobile for Cordova app
$html .= <<HTML
<img src="/images/products/$path/$id.$rev.$size.jpg" width="$product_ref->{images}{$id}{sizes}{$size}{w}" height="$product_ref->{images}{$id}{sizes}{$size}{h}" alt="$alt" />
<img src="$images_subdomain/images/products/$path/$id.$rev.$size.jpg" width="$product_ref->{images}{$id}{sizes}{$size}{w}" height="$product_ref->{images}{$id}{sizes}{$size}{h}" alt="$alt" />
HTML
;
}
Expand Down Expand Up @@ -2001,7 +2002,7 @@ sub extract_text_from_image ($product_ref, $id, $field, $ocr_engine, $results_re
}

my $image = "$www_root/images/products/$path/$filename.full.jpg";
my $image_url = format_subdomain('static') . "/images/products/$path/$filename.full.jpg";
my $image_url = "$images_subdomain/images/products/$path/$filename.full.jpg";

my $text;

Expand Down

0 comments on commit 273676f

Please sign in to comment.