Git Product home page Git Product logo

Comments (4)

johndatserakis avatar johndatserakis commented on May 24, 2024 1

Hey yea I definitely hear what you're saying. In the future we'll take a look at keeping the smaller images at their uploaded size. Thanks for the feedback and good luck!

from file-upload-with-preview.

WriterStat avatar WriterStat commented on May 24, 2024 1

You as well! Fun project. Always good to see people working in the community and sharing. Best, -C

from file-upload-with-preview.

johndatserakis avatar johndatserakis commented on May 24, 2024

Hi there - thanks for checking out the project.

I see what you're saying about not forcing an image that's smaller than the image preview pane to stretch to fill it.

Luckily I think the fix for this should be pretty simple. The image is stretching because of the background-size: cover; property set on the .custom-file-container__image-preview. How about you add the following code to your .css stylesheet so it overwrites the repo's style.

.custom-file-container__image-preview {
  background-size: contain;

  /* You may want to add this too because the background of the image-preview container is set to a white color. */
  background-color: #eee; 
}

Try that and let me know how it goes.

from file-upload-with-preview.

WriterStat avatar WriterStat commented on May 24, 2024

Hi, much thanks for the note back. Welcome!

background-size: contain; will scale the uploaded image preview up so that each side is as large as possible while not exceeding the length of the corresponding side of the container. So if you are using this for one image and the container is 400px by 400px; Then the image will be scaled to that as well. Or if 200px by 300px then the image will be scaled to 200px by 200px. If the image is smaller than the container's smallest bounding side, it's likely to still scale up/blurry to fill to the length of that side.

The preview pane for use with one image would either need to shrink to fit the image size or the image would need to ignore the container size if the container size is fixed. And be centered.

Optimally a preview image for use with one uploaded image would be the size of the original image/keep it's dimensions unless larger than the container. Note: this isn't a problem with multiple files but only when using it on the single image upload. As the multiple creates really small preview images already.

But when using it for the one image upload/preview and using either background-size: cover; or background-size: contain; will still scale a smaller image size up to the preview container size/blurry/lose it's original size.

Anywho looks promising but we've gone in another direction, with something created in house.

Best,

-C

from file-upload-with-preview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.