Skip to content

Commit

Permalink
Allow ?width= to be read from image urls and then used to size image
Browse files Browse the repository at this point in the history
  • Loading branch information
jolzee committed May 27, 2020
1 parent cbc6080 commit 44e9982
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/components/ImageAnimation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@
<!-- </transition> -->
</template>
<script>
var getParams = function (url) {
var params = {};
var parser = document.createElement('a');
parser.href = url;
var query = parser.search.substring(1);
var vars = query.split('&');
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
params[pair[0]] = decodeURIComponent(pair[1]);
}
return params;
};
export default {
props: {
url: {
Expand All @@ -32,10 +46,12 @@ export default {
},
methods: {
determineMaxHeight() {
if (this.url.includes("/weather/")) {
return 100;
let params = getParams(this.url);
if (params.width) {
return params.width;
} else {
return "230";
}
return "230";
}
}
};
Expand Down

0 comments on commit 44e9982

Please sign in to comment.