Skip to content

Commit

Permalink
Reduce image size
Browse files Browse the repository at this point in the history
  • Loading branch information
vbaranov committed Sep 8, 2021
1 parent 618ef0b commit c4aca47
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions apps/block_scout_web/assets/js/lib/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const resultItemElement = async (item, data) => {
item.style = 'display: flex;'

item.innerHTML = `
<div id='token-icon-${data.value.address_hash}'></div>
<div id='token-icon-${data.value.address_hash}' style='margin-top: -1px;'></div>
<div style="padding-left: 10px; padding-right: 10px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden;">
${data.match}
</div>
Expand All @@ -96,7 +96,7 @@ const resultItemElement = async (item, data) => {
const $searchInput = $('#main-search-autocomplete')
const chainID = $searchInput.data('chain-id')
const displayTokenIcons = $searchInput.data('display-token-icons')
appendTokenIcon($tokenIconContainer, chainID, data.value.address_hash, data.value.foreign_chain_id, data.value.foreign_token_hash, displayTokenIcons)
appendTokenIcon($tokenIconContainer, chainID, data.value.address_hash, data.value.foreign_chain_id, data.value.foreign_token_hash, displayTokenIcons, 15)
}
const config = (id) => {
return {
Expand Down
7 changes: 4 additions & 3 deletions apps/block_scout_web/assets/js/lib/token_icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ function getTokenIconUrl (chainID, addressHash) {
}
}

function appendTokenIcon ($tokenIconContainer, chainID, addressHash, foreignChainID, foreignAddressHash, displayTokenIcons) {
function appendTokenIcon ($tokenIconContainer, chainID, addressHash, foreignChainID, foreignAddressHash, displayTokenIcons, size) {
const iconSize = size || 20
var tokenIconURL = null
if (chainID) {
tokenIconURL = getTokenIconUrl(chainID.toString(), addressHash)
Expand All @@ -35,12 +36,12 @@ function appendTokenIcon ($tokenIconContainer, chainID, addressHash, foreignChai
.then(checkTokenIconLink => {
if (checkTokenIconLink) {
if ($tokenIconContainer) {
var img = new Image(20, 20)
var img = new Image(iconSize, iconSize)
img.src = tokenIconURL
$tokenIconContainer.append(img)
}
} else {
identicon.generate({ id: addressHash, size: 20 }, function (err, buffer) {
identicon.generate({ id: addressHash, size: iconSize }, function (err, buffer) {
if (err) throw err

var img = new Image()
Expand Down

0 comments on commit c4aca47

Please sign in to comment.