ecency / ecency-vision

Immutable, decentralized, uncensored, rewarding communities built, owned and operated by its users
https://ecency.com
MIT License
58 stars 57 forks source link

Add image ratio into json_metadata #1156

Closed feruzm closed 1 year ago

feruzm commented 1 year ago

During image uploads, we usually know ratio and size of image, width and height. Consider adding that info into content json metadata with new array, not all images maybe only top 5. Only uploaded images obviously, not linked images.


image_ratio: [{
   "url": "image url",
   "width": 1234,
   "height": 3214
  },
  {
   "url": "image 2 url",
   "width": 1235,
   "height": 3215
  }...
]
igormuba commented 1 year ago

@feruzm Just updating, on the branch https://github.com/ecency/ecency-vision/tree/image-ratio-json-1156

And on the commit https://github.com/ecency/ecency-vision/commit/e17ce6a9fd13e7983333547ecc36913d228cda4b

I can currently get the width and height, but Javascript works in mysterious ways, so when it publishes to the blockchain the image_ratio goes as an empty array. I thought I was doing all the async magic correctly but I might be missing something. Will get back to this issue later with a fresh mind.

igormuba commented 1 year ago

@feruzm it is working for the update function, I am working on the publish function and the save draft. Still need to figure out how to discern the uploaded ones.

Question: Why do we want those ratios? And why only uploaded and why only the first ones? Once uploaded I see no difference in the images that are uploaded and the ones that were added from external websites, they all are URLS in the metadata and the body

feruzm commented 1 year ago

@igormuba from what I see, we are potentially loading images to get ratio. Initially I thought, we can get from uploaded images, but if we are loading all images anyway, best to add top 5-10 images and their ratio. Ratio we need on mobile app side and later on better image loading effect. If you know beforehand ratio or size of image, you can create nicer looking image loader that will cause minimal content shift which is highly recommended by google for seo purposes.

igormuba commented 1 year ago

@feruzm I couldn't figure out how to gt the ratios from the uploaded images. On my last commit on the branch I limited to 5 images, it is going to save RC. I myself have plenty of RC to spend but I have friends that needed delegations and the less we put into the json metadata for those users the better

If any suggestions appear on how to get the ratios alternatively it is appreciated

https://github.com/ecency/ecency-vision/pull/1167