How can I make input element for an Image nextjs with sanity backend? - image

How can I make input element for an Image nextjs with sanity backend?
I made a basic post schema in sanity io, and I linked to nextjs, I want to make create new post in next js, what I couldn't do is Image input element , It didn't work like other inputs .
Do you have any suggestion or example ?

Related

Extract image link from TinyMCE in Laravel

I'm making an image sitemap for my site I'm trying to extract the image link from the post and I'm using the TinyMCE text editor Need Help pls.
I use this code but the problem is I do this in the controller and I can't do it in the view This code being in the Controller leads to two problems, first, that I will not be able to all the images for one post, but I have to fetch the images of all posts together at once. The second thing or the second problem is that this code extracts the images twice: the link I want and the link inside So I want a solution so that I can extract images for one post
Below is a picture of the code in the controller

Hitting 2 URLS using an anchor tag in Laravel

I have got an ancor link tag on the DOM and would like to hit 2 URLS once it is clicked, the endpoints are route('b2c.receipt') and route('b2c.flushData')
Download Receipt
You won't really be able to do this with a raw anchor tag.
Given the name of your second route, flushData, it may be that you can incorporate the "flush data" logic into the first route's controller function.
If not, you're going to need to use JavaScript to fire off two AJAX requests.

Laravel 5.5 and VueJS, use both together correctly in a tags app

I guess this question has already been posted in different forms over time, but I still didn't find the answer I'm looking for:
I'm having trouble implementing vueJS in my Laravel app, I want to keep server and front-end very much separated but in this case it doesn't seem so easy. I have the classic blog project, where every article has some tags associated with it, so there's a classic many-to-many relationship and everything is set.
When I edit an article, I wanna have a section where all the tags are displayed and also you can add a new tag (very stackoverflow-like), what I wanna achieve is that my Javascript (and so my vue) only manages the rendering of those tags on the page, so that when I enter in the edit page I can see all associated tags, BUT, i only want to edit the input tag inside my form, I don't want to do a POST request in Vue, I want to keep it PHP, I want laravel validation, I don't want to write another one for the javascript.
I want javascript to only edit the DOM when I want to add a tag, so that I insert a new one and it immediately gets pushed inside the already existing array of tags, so in real-time the tags are updated, but when I submit the form it is my PHP that handles the server request, not vue, and this for now seems impossible because in order to update the tags correctly when adding one (or removing one), the data inside vue needs to have a list of tags, otherwise it won't work.
This means I have to create a new route (for example /tags/{article_id}) and a new controller function in order to return tags associated with that article, so this also means that I can't give to PHP the tags that I rendered (cause for example they're in a list, not an input select (due to the appearence I want to give)) isn't there a cleaner way to do this?
I'm trying to wrap my head around vuejs but sometimes it feels like stuff would be easier in jQuery (?), I don't know... I hope I explained myself correctly.

MVC4 render image with Ajax call

Masters,
I have a scenario where i have a list of Items and on clicking single item it gets details along with image src url using ajax call.
I want to display(render) image right on page.
Now Image source URL is a FileActionResult returning Base64 string.
The problem is the page does not render image although it is having correct Src URL.
And I don't want any additional Ajax call.
Please Help.
Thanks in advance.
How are you forcing the image to be updated?
The DOM is going to keep the image the same until you tell it to refresh the image -- I would suggest using something like
document.getElementById('theImg').src="/newImg.gif?unique=someuniquestring";
where someuniquestring is a new random datetime or something (to make sure browsers like IE don't cache the GET request).

Upload file using input tag(without rails/html form) and paperclip in rails

I am a kind of new on ROR, I want to upload an image using simple input tag and don't want to use form for that. The basic functionality of Paperclip is known to me. If I am not wrong then the format of object that is being passed to save image is :
"image_object"=>
[#< ActionDispatch::Http::UploadedFile:0xb5ad25f4
#content_type="image/gif",
#headers=
"Content-Disposition: form-data; name=\"pic[]\"; filename=\"test.gif\"\r\nContent-Type: image/gif\r\n",
#original_filename="test.gif",
#tempfile=#<File:/tmp/RackMultipart20131112-17750-1lprijc>>]
I want to upload image using the following steps:
1. Using Jquery, I want to fetch the appropriate details(file parameter) of selected image in input tag and send those using Jquery/ajax.
2. By passing that parameters to rails controller I want to use those details to generate an object(as sample shown above) that can be used to save Image in my application.
My questions are:
1. which Jquery method should I use and what are the parameters that are necessary to generate the image object?
2. On controller side, how to generate Image Object using those details?
Thanks in advance.
I'm not sure if I understood your question right. But based on the details you provided there are many options you can go for.
The simplest one is as follows:
Just add :remote => true to the rails form and submit the form and on the controller side you can create the object.
But if you want to be able to upload an image through a REST API then this link should help.
You can visit the SO question as well here which describes exactly what u want.

Resources