I have question, is it possible to add more images and HOW, to existing product, that already have some images in gallery, because when I now use update product endpoint PUT /wp-json/wc/v3/products/<id> https://woocommerce.github.io/woocommerce-rest-api-docs/#update-a-product
and send
{
"images": [
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg"
},
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg"
}
]
}
it just removes all existing images and it has only those two images in gallery. So I wonder is it possible to add new images to those that already exist.I need to send 10 images and then new 10 and so on.. So I want to know is it possible to send new images to existing product and show old and new images in gallery of that product.
Related
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.
I have a following piece of code:
function get_first_image_url($html) {
if (preg_match('/<img.+?src="(.+?)"/', $html, $matches)) {
return $matches[1];
}
}
How can I change it to be able to get the thumbnail instead of first image?
It depends entirely on how your theme is set up. Some may be placing the thumbnail as a background image source, in an entirely new div, etc., and it may vary on each and every page template.
Luckily WordPress has a slew of functions to help you grab the thumbnail programatically without parsing the HTML, such as get_the_post_thumbnail(), get_the_post_thumbnail_url(), wp_get_attachment_image(), and multiple others that allow you get the the thumbnail based on the post ID, image ID, or whatever fields you have access to at that point.
There's also some non-native functions people have come up with that will fetch the attachment ID based on the URL (like a reversewp_get_attachment_image()) which would allow you to grab the "thumbnail size" based on the URL if that's what you need: Get attachment ID by file path in WordPress
Hi i am working on a photo gallery. Here all images are coming from mysql database table. The images are uploaded from the admin panel. I am using php to upload and fetch images from database table. Till here all things are working fine. Now i have to implement a system where user should be able to define the position of the image in the image gallery and image positions should be swiped with one another image. In the gallery page I am showing 16 images in four rows and after that pagination starts. So will it be possible to implement such a system in my image gallery?
If I understand what you want to do correctly then you might want to check out this jQuery plugin: http://isotope.metafizzy.co/
I want to post into community wall post with attached image. If I use simple api call to /page/feed with picture arguments it inserts a small image. But I want to attach big image, for example, from gallery. When I upload photo to gallery it automatically posts to wall. But when I post >= 3 photos all that posts are merged into single one with all inserted images.
The question is how to get different post for each uploaded image? Or maybe I can attach to /page/feed api not picture only, but image which would be uploaded into album?
Thanks
When you say "attach big image", I assume you are POSTing to /PAGE_ID/photos, right?
If you upload 3 or more images, yes, they will be collapsed when they are displayed in the page's feed. This is a "feature" of feed that organizes and collapses images that were uploaded together.
Imagine if you uploaded 20 photos to the page and they weren't collapsed; the feed would be dominated by the photos and it would be hard to see any other content (like content that was published slightly before the uploaded photos).
If you can provide a screenshot of what you are seeing, I can confirm this.
And yes /PAGE_ID/feed with picture is a thumbnail for a post. Example: a thumbnail to accompany a post containing a paragraph of text (or a link).
https://developers.facebook.com/docs/reference/api/page/
I have created an application using php which upload images into user's profile.After image is uploaded, User is directed to another page which display the uploaded image. Here I need to display comment box of the image including comments posted by friends.
I have fully access to the uploaded image(id of the image,source,link,etc.)
I tried this with usual facebook comments plug-in which is given bellow.
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:comments href="APP_URL" num_posts="2" width="500"></fb:comments>
I tried replacing APP_URL with
1) source link of the image eg: http://a5.sphotos.ak.fbcdn.net/photos-ak-snc1/v5041/89/51/40796308305/n40796308305_1960517_6704612.jpg
2) facebook link of the image eg: http://www.facebook.com/photo.php?pid=1960517&id=40796308305
(above links are just examples taken from facebook developer page)
but non of them do what I want.It display the comment box.But after I posted a comment,it is not available in users profile page(it doesn't update the image comment box which is in users profile)
Can anyone please help me with this?
I need to get the comment box of a image into my facebook application.
Or if there is a way load whole image display page(image,comment box,Tag This Photo button,Share button,etc.) inside my app window, please let me know
The comments dialog is intended to be used with a photo posted to Facebook, but intended to be a simple comments plugin for websites. In order to do what you want, you'll have to use the graph api:
This will get you the photo, where the number at the end is the id:
http://graph.facebook.com/40796308305
Adding comments to the end (with a valid access_token from your app) will get the comments for the photo:
http://graph.facebook.com/40796308305/comments
You can also post to this url to allow users of your app to add comments to the photo. Here's the link for the graph API with photos: Photos
Hope that helps!
Edit for more clarity:
Okay check it out, I can do to my profile feed at (I added an access_token to the hyperlink):
http://graph.facebook.com/me/home
I get a result that looks something like this (truncated):
{
"data": [
{
"id": "6400518_2123759246396",
"from": { ... },
"to": { ... }
},
"message": " ... ",
"picture": "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-snc6/####.jpg",
....
"type": "photo",
"comments" : { ... comments are here ... }
What does this mean?
Using this data you can see that the post on my wall with id 6400518_2123759246396 has the type: photo, so you know it is a photo. Furthermore, you can get the comments on the photo by accessing the comments : { .... } data.
If you would like to allow users to add more comments to this post. You would need the users to have authenticated your app with the correct permissions ( see the documentation on publishing for more info on that). Sorry about the confusion.