Skip to content

Commit c6066b9

Browse files
committed
fix amp img ratio error
1 parent 1dd1da6 commit c6066b9

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

themes/hugo-coder/layouts/dev/single.amp.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ <h1>{{ .Title }}</h1>
2323
<div>
2424
{{ $PATTERN_EMPTY_ALT := "<img src=\"([^\"]+)\" alt=\"([^\"]+)\">" }}
2525
{{ $PATTERN_ALT := "<img src=\"([^\"]+)\" alt=\"\">" }}
26-
{{ $REPLACEMENT := "<amp-img src=\"$1\" alt=\"$2\" layout=\"responsive\" width=\"266\" height=\"150\"></amp-img>" }}
26+
{{ $REPLACEMENT := "<div class=\"fixed-container\"><amp-img class=\"contain\" src=\"$1\" alt=\"$2\" layout=\"fill\"></amp-img></div>" }}
2727
{{ $outContent := .Content | replaceRE $PATTERN_EMPTY_ALT $REPLACEMENT | replaceRE $PATTERN_ALT $REPLACEMENT | safeHTML }}
2828
{{ $outContent }}
2929
</div>

themes/hugo-coder/layouts/money/single.amp.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ <h1>{{ .Title }}</h1>
2323
<div>
2424
{{ $PATTERN_EMPTY_ALT := "<img src=\"([^\"]+)\" alt=\"([^\"]+)\">" }}
2525
{{ $PATTERN_ALT := "<img src=\"([^\"]+)\" alt=\"\">" }}
26-
{{ $REPLACEMENT := "<amp-img src=\"$1\" alt=\"$2\" layout=\"responsive\" width=\"266\" height=\"150\"></amp-img>" }}
26+
{{ $REPLACEMENT := "<div class=\"fixed-container\"><amp-img class=\"contain\" src=\"$1\" alt=\"$2\" layout=\"fill\"></amp-img></div>" }}
2727
{{ $outContent := .Content | replaceRE $PATTERN_EMPTY_ALT $REPLACEMENT | replaceRE $PATTERN_ALT $REPLACEMENT | safeHTML }}
2828
{{ $outContent }}
2929
</div>

themes/hugo-coder/layouts/partials/stylesheet.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,18 @@
122122
a{padding:0;color:#ff1d55}.boxes .box p{color:dimgray;font-size:12px;margin:7.5px 0}@media (max-width:900px){.boxes
123123
.box{-ms-flex-preferred-size:45%;flex-basis:45%}}@media (max-width:500px){.boxes
124124
.box{-ms-flex-preferred-size:100%;flex-basis:100%}}
125+
126+
.fixed-container {
127+
position: relative;
128+
width: 100%;
129+
height: 300px;
130+
margin: auto;
131+
}
132+
133+
amp-img.contain img {
134+
object-fit: contain;
135+
}
136+
137+
.footnotes {
138+
overflow-wrap: break-word;
139+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!-- inject your link rel stylesheet here !-->
1+
<!-- inject your link rel stylesheet here !-->

themes/hugo-coder/layouts/self/single.amp.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ <h1>{{ .Title }}</h1>
2323
<div>
2424
{{ $PATTERN_EMPTY_ALT := "<img src=\"([^\"]+)\" alt=\"([^\"]+)\">" }}
2525
{{ $PATTERN_ALT := "<img src=\"([^\"]+)\" alt=\"\">" }}
26-
{{ $REPLACEMENT := "<amp-img src=\"$1\" alt=\"$2\" layout=\"responsive\" width=\"266\" height=\"150\"></amp-img>" }}
26+
{{ $REPLACEMENT := "<div class=\"fixed-container\"><amp-img class=\"contain\" src=\"$1\" alt=\"$2\" layout=\"fill\"></amp-img></div>" }}
2727
{{ $outContent := .Content | replaceRE $PATTERN_EMPTY_ALT $REPLACEMENT | replaceRE $PATTERN_ALT $REPLACEMENT | safeHTML }}
2828
{{ $outContent }}
2929
</div>

0 commit comments

Comments
 (0)