How to upload images with the Dashboard and know the image URL using cloudinary? - image

Goal: My goal ist to upload images and a) keep the original name and b) know the exact URL path.
I set the Upload preset to:
Overwrite: true
Use filename or externally defined public ID: true
Unique filename: false
Delivery type: upload
Access mode: public
When I upload images using the Dashboard Media Library my images keep the original filename (which is great) but cloudinary adds a unique ID  "v1585290075" into the URL.
https:// strong textres.cloudinary.com/xxxxx/image/upload/ => v1585290075 <= /2020-03-27-ee-apps/xxxxxxx.png
This unique ID prevents me from knowing the exact URL. 
Question: How can I upload images and avoid getting the unique ID in the URL??

The Unique ID you're referring to is a version component that you can utilize to bust the CDN's cache (see here). It is not mandatory and you can safely remove it and the images will still show.

Related

how get laravel file manager image thumbnail

I install the Laravel file manager package in my app. but already I cant use thumbnail images in the blog.
How can I get an image thumbnail of uploaded photos when I use Laravel file manager?
After much searching, I realized that such a function does not exist (at least until the time of writing this message).
I defined a function in the helper that returns the address of the thumbnail from the URL of the original image.
The reader should note that these definitions may differ based on the setting of parameters for another person.
function LMFThums($url)
{
$url2= str_replace(basename($url) , '', $url ) ;
$url2=$url2.'thumbs/'.basename($url);
return $url2 ;
}

Gatsby: How to display a list of images specified in a yaml file?

I use the current version of Gatsby (2.x) and want to use gatsby-image for rendering a gallery for products.
I have several YAML files for products. I can already create pages with the text content of these files but I also want to add a small gallery with images specified in the .yaml file.
An example YAML file looks like this:
product: "Some product"
description: "It is really awesome!"
screenshots:
- /img/product1/screenshot1.jpg
- /img/product1/screenshot2.jpg
- /img/product1/screenshot3.jpg
My problem now is that I can get the screenshots only as strings but I have no idea how to pass them to for rendering.
I thought of creating a component that takes the file name and uses a query to get the image data - but it can't take any parameters because it can only use static queries.
I've also not found a way to pass results from the first graphql query to a second for the image data.
If you install gatsby-transformer-sharp and gatsby-plugin-sharp and use a correct path to your images, Gatsby will automatically pick those up and pipe them through sharp, hence you can query those images. You can have a look at one of my sites which also uses a YML file with image paths that I then use with gatsby-image: https://github.com/LekoArts/gatsby-starter-portfolio/blob/master/src/sites/sites.yaml

Extracting image dimensions in the background with Shrine

I have set up direct uploads to S3 with Shrine. This works great. Among others, I have the following plugins enabled:
Shrine.plugin :backgrounding
Shrine.plugin :store_dimensions
Shrine.plugin :restore_cached_data
Correct me if I'm wrong but image dimensions extraction appears to be done synchronously. If I let the user bulk upload images via Uppy and then persist them all, this seems to be taking a long time.
What I'd like to do is perform image dimensions extraction asynchronously - I don't need the dimensions available for the cached file. If possible, I'd like to do that in the background when the file gets promoted to the store. Is there a way to do it?
The way I got this to work is by making use of :refresh_metadata plugin, instead of :restore_cached_data which I used originally. Thanks to Janko for pointing me in the right direction.
Reading into the source code provided some useful insights. :store_dimensions plugin by itself doesn't extract dimensions - it adds width and height to the metadata hash so that when Shrine's base class requests metadata, they get extracted too.
By using :restore_cached_data, this was being done on every assignment. :restore_cached_data uses :refresh_metadata internally so we can use that knowledge to only call it when the file is promoted to the store.
I have :backgrounding and :store_dimensions set up in the initializer so the final uploader can be simplified to this:
class ImageUploader < Shrine
plugin :refresh_metadata
plugin :processing
process(:store) do |io, context|
io.refresh_metadata!(context)
io
end
end
This way persisting data we get from Uppy is super fast and we let the background job extract dimensions when the file is promoted to the store, so they can be used later.
Finally, should you have questions related to Shrine, I highly recommend its dedicated Google Group. Kudos to Janko for not only creating an amazing piece of software (seriously, go read the source), but also for his dedication to supporting the community.

How to serve static profile images in node

This is really more of a "using what method" than a "how-to" question. I am creating a site in NodeJS with Express. So, each user has the ability to upload a profile picture, and my concern is how to route requests for these images. A couple of questions I have are:
Can I use express.static() to serve a default file if a valid one isn't specified? If not, am I going to have to specify a GET route for /img/profileand handle the FS querying there?
How can I find the correct image if multiple file extensions are allowed? (I originally just removed the file extension and they appeared in img tags anyway, is that okay?)
I am currently naming all pictures after their user's name. Looking ahead into the future (for apps I may have to scale), what are normal naming conventions for static user content? Are most stored with a UUID referencing the content in the database?
What else should I take into consideration that I may not have accounted for yet?
First question:
At present, I'd recommend storing your images in a predictable location that can be inferred from some combination of columns or fields in your database entries. One of those fields or columns would be a filename (accounts for different extensions). Then, if they haven't uploaded an image, you just lay down in your view code a reference to the generic "has not set an image" file.
express.static obviously can server static files, but it currently doesn't have a way to serve some other file if the one you wanted isn't there. Because this sounded like fun, I made some modifications to static to support what you request and submitted a couple of pull requests (the feature touched 2 different modules):
In send: https://github.com/visionmedia/send/pull/33
In connect: https://github.com/senchalabs/connect/pull/999
I don't know if those will get included in the project, but if you want to see my forks that have these changes, they are here:
https://github.com/bigohstudios/send
https://github.com/bigohstudios/connect
If this went through, you would mount a static at the root of your profile image files:
app.use(static('<profile image files root>', { fallback: 'anon.jpg'}))
Second question
I generally store the extension in my DB, then when I load the image, I have the correct extension to put into the src attribute on the img tag.
Third question
If you can guarantee unique names, then using those would work. I prefer using the DB id or a UUID as you suggest. It's less intuitive when scanning all the image uploads, but I rarely find myself doing that. I'm usually hunting for a specific image, and I can look up the identifier for that as needed.
Fourth question
You may end up storing the static content outside your app server (e.g. on S3). If that happens, then of course static won't help you.

Return Places nearbysearch with only 'my' locations loaded to 'Bulk Uload Tool' against my API/ID

GOAL:
I am working to return a result set of locations via the types=other parameter so that I can ensure ONLY MY locations are part of the result set.
Question/Scenario 1:
I am able to submit place/add for a location and retrieve that location with nearbysearch, however I am not able to add all my data via this method such as hours, image, url, etc. Is there formatting to support this data upload in the place/add?
Question/Scenario 2:
I have uploaded my locations in the 'Bulk Upload Tool' under my ID that is associated to my API key. In the upload I included the category 'Other'. None of these locations return in my nearbysearch result set. Should they return? If so, does anyone have insight to how?

Resources