How to make an image selector for specific content - php

When creating a new page I want to select an image from a gallery of all images previously uploaded. I've tried searching for a solution for a few hours but can't seem to find any good answers. I already know how to upload and display the images to a gallery from the database.
What I don't know is how to make it so you can select an image and assign it to that page/content.

It's not something that happens automatically. You have to code it.
The algorithm would look something like this:
Display thumbnails with the url/id of the full size picture (see Creating a thumbnail from an uploaded image);
On click, add the url of the picture you want to use on that page.

Related

Can't see URL to specific image in wordpress

guys I want to send some photos to my friend but when I want copy specific photo URL from gallery, so I can copy just gallery URL no photo. Is there any way to change it to see URL for photo ? I attach some photos for better explain.
I tried to change permalinks in settings and also watched in gallery, but in gallery are no settings. But I found that gallery is using ModuloBox.
This is how is URL in gallery preview
Here you can see that URL is same like in gallery
And this is what I need (watch URL)
There is a share option in the top right of your gallery which generates a link for you:
https://www.flyingslovak.eu/galleries/slovakia/?guid=photography_gallery_5273&mid=8
Have you tried to open the image you want in the slider, then right clicking on the large image and choosing 'Open image on a new tab'? Not quite sure thats the right wording, but it is something like that.
In the new tab you get the URL for the image - something like www.example.eu/wp-content/uploads/2019/01/01.jpg

how to convert text to image in wordpress and create thumbnail

hi i have a wordpress at lesprenoms.quebec it's listing the name of people with a short description.
if you take a look at this post:
http://lesprenoms.quebec/qeZN30e9
it's a simple div with image as background with text on top and an other image at the bottom what i want is that wordpress generate all the thumbnail i want and also the one for facebook witch is 750*394px crop top when i hit publish or like save the draft and else and that it get update if i change the text on top of the image.
some will tell me to do this trough photoshop and else witch i already did for the 170 other image but i think i can made template, then just upload the image and just add my text that all trough the website without having to fire photoshop witch can be really usefull as if i'm on other computer and else...
so i know there a way to do this in php with maybe imagefttext or something like that. All the thing is wrap in a div so maybe a function that get all the text + image between the first and the last could be really nice and neat.
so if someone can help cause i really need your help guy...

Can I un-cache one image? Or should I do things differently?

I allow users to add a profile picture of themselves to an account, pretty standard stuff.
To make things simple, when they update their image I simply overwrite the image they currently have stored (its not a big part of what we do so simple approach)
So, page is shown with their current image, they can then choose to upload a new one, the uploaded file is then saved, image URL updated in MySQL table and page is displayed again.
The image is uploaded correctly, MySQL table updated correctly, but the image is cached so old image shows on page even though they have uploaded a new one.
Can I un cache one image? Is there a better way to do this?
For avoiding image caching you can simply add a query sting in the image src. Best would be adding a date time.
{$t = getDate();}
and in your image src add: src= "path.jpg?t=".$t
For this you need not to change anything for new image..Date time automatically gets changed every second ;)
Hope it helps..
Use versioning. In the link for the image, instead of abc.jpg say abc.jpg?v=5. And when a new image is uploaded, change the number.
see this question

Logic to display the correct selected thumbnails?

I am using Wordpress - I am wondering if it could work with posts'feature images and links as content?
In form, there would have brochure images (PDF thumbnails) with checkboxes. The user will select one or more thumbnails. On thank you, there would be correct selected thumbnails for the user to download pdf files.
So how to have posts display with checkboxes and then on thank you, how to display correct ones with links wrapped around them?
the help or insight would be appreciated. The image can help u to see what I am trying to achieve:
OR we do static things - how do I get the checkbox selected then display the correct pdf?
My idea, not very dynamic:
upload the pdf
copy the url of the pdf
make a new post (maybe create a custom post type for this)
paste the pdf url in a 'custom field'
add the featured image to the post
publish the post
on the frontend
query all posts which have a pdf on them.(based on posttype/tags/category whatever)
Make a list
show the featured image (you know how)
save selection on post ID (on submit)
show selection on post ID , get both the featured image and the pdf link.
Not the most graceful solution but that's how I would do it.
I would use a custom post type. Since the post doesn't need an title or body(text)

How do I make a gallery in WordPress without using a plugin?

I have created a gallery in a WordPress post using WordPress's native media gallery and it shows me the images as gallery thumbnails in rows and columns which is exactly what I want.
But when I click on any of the thumbnail it opens the direct image link. I want that the image should be shown in my blogs environment. I would actually want it to show on the same page itself. but if not that I don't want it to open as a direct image. Is there a template file or something I could make for opening those images. I think image.php, but I have no idea how to go about it.
Help..?
Thanks
When you're inserting a gallery into your post, you can select how to link to the images. See screenshot: http://cl.ly/2yYA
Just select 'attachment page' and you'll get an individual page with commenting for that photo. Is that what you were looking for? You can edit the template of that page using attachment.php.

Categories