Get album ID from Google Photos outside Helper page
-
Hi
Is it possible to get an album ID from Google Photos outside of the Helper page or Visual Editor “work-flow” screen?
The reason I ask this: I want that users put the album ID in a custom (ACF) field so I can pass the value with php to a shortcode. I don’t want users to work with the WorkFLow editor, so they don’t have to choose the right options.
I will define all the options in the shortcode in php, so all the albums on the website looks the same.
The users who may add an album don’t have the capabilities to access the Helper page.
Thank you in advance!
Peter
-
Very interesting requirement!
I wanted to understand more about what you were requesting, so I went through the other posts you have on this forum. It looks like you are trying to replace this plugin with Photonic, and specifically you are trying one of the following:
- To be able to simply specify the album id to pass to the shortcode (with all other parameters being defined by the options)
- And / Or to be able to use some sort of a template file to customize the appearance
The ability to define your own type of template file looks very interesting and is something I will definitely consider for a future release.
Regarding the specification of an album id, this is a bit tricky because it is contextual, and the underlying fundamental differences between the Embed Picasa plugin and Photonic come into the picture. E.g.:
- In Embed Picasa you defined a user upfront, and that user’s albums could get pulled, but in Photonic (while Picasa was alive) you could specify a different user in each shortcode, essentially letting you use the plugin with multiple users. This model still exists for Flickr, SmugMug and Zenfolio. Of course, with Google Photos that distinction goes away
- In Embed Picasa you could only display photos from a single album, but in Photonic you can also display all your folders together, then see the photos in each album (e.g. https://aquoid.com/plugins/photonic/google-photos/albums/)
- Embed Picasa caters to Picasa, but Photonic caters to multiple providers and each provider has different types of constructs
In essence, any sort of a list of albums has to be contextual (even in the helpers page you had to pass the Picasa user’s name to get the list of albums), so it is considerably harder to pre-populate the list in the editor directly. The Workflow solves this problem by letting you progressively build the shortcode / block.
What makes it worse is that if a plugin has to work with Gutenberg, that exponentially raises the complexity! E.g. I would have to define individual blocks for each type of provider and construct, such as “SmugMug Folder block”, “SmugMug Album block”, “SmugMug Photos block”, “Google Album block”, “Google Photos block” etc. Moreover, it would become a lot harder for you to implement your functionality using ACF.
Basically Photonic is trying to solve a more complex problem, hence it needs a more complex model of implementation.
That being said, I have a question about this:
The users who may add an album don’t have the capabilities to access the Helper page.
I wasn’t able to follow this. People editing the posts would have the
edit_posts
capability, and to use Photonic → Helpers you need to have theedit_posts
capability too. So why would the users not have capabilities to access the Helpers? Note that the users cannot access the options or authentication page – that needsedit_theme_options
capability which administrators have. But people editing posts should be able to use the helpers.Happy to discuss more!
Hi Sayontan,
First of all, you are good, very good! I follow this forum for more then a year (I receive an email notification when the words “Picasa” or “Google Photos” are used on this forum) and it’s impressive to see your support is very good. It’s amazing how much time you spend to make this free(!) plugin better and answering all the questions on this forum very accurate.
The custom template option of “Embed Picasa” was very handy, but now it’s not necessary for me anymore.
I understand the differences between Embed Picasa and Photonic and I see your plugin is more complex and the new Google Photos API didn’t make it easier.
About the edit_posts capability…
I have different post types like “albums”, “events”, “announcements”, “sponsors”, etc. and have custom capabilities for every post type, like “edit_albums”. The different capabilities are assigned to different roles.
The role “photographer” has the capability “edit_albums”, but may not edit normal posts. He also don’t have access to the helper page.Gutenberg will not be a problem for me. I display the albums outside the “content part” by editing the “single-album.php” template and put the code under the “content”.
I already have the “pass method” working. I use the plugin “Custom Content Shortcode” (amazing plugin, you will love it) to do this.
With ACF I have created a custom field called “google_photos_album_id” to display on the edit screen of the “albums” posts. I have added an album id from the helper page in the field and saved it. Then in the php template I used this code:
<?php start_short(); ?> [pass field=google_photos_album_id] [if pass='{FIELD}' empty=false] [album type='google' view='photos' album_id='{FIELD}' main_size='1600' tile_size='288' layout='random'] [/if] <p>Field value: {FIELD}</p> [/pass] <?php end_short(); ?>
When I display the album post, the photos are loading correctly, so it works.
The only problem is that if a user is not authorized to edit posts, he don’t know the ID for the album he wants to display.
Is it (for example) possible to extend your album shortcode with an attribute like “display_id=true” that will show the ID of an album after every album thumbnail (like on the helper page), so I can use the album shortcode on a (hidden) page where the user can see the ID of every album and copy it?
Thanks again!
Peter
- This reply was modified 5 years, 10 months ago by Peter Berger.
Thank you for the details of your requirement – they help me understand the challenges better.
Is it (for example) possible to extend your album shortcode with an attribute like “display_id=true” that will show the ID of an album after every album thumbnail (like on the helper page), so I can use the album shortcode on a (hidden) page where the user can see the ID of every album and copy it?
This is going to be a bit challenging representation-wise.
However, I can consider doing this – just like I have the helper page in the back-end, I can do a set of helper-shortcodes that will take the same parameters that the helpers do and give you the output in the same format as the helpers.
Does that help? You can then call the helper shortcodes on any page and get the details in the output. This way I will not have to modify my core functionality too.
Hi Sayontan,
Thank you for your reply.
Does that help? You can then call the helper shortcodes on any page and get the details in the output.
Oh yes, that will help me a lot! It should be extra really nice if its possible to define that I only want to show (in my case) the “Google section” of the helper page and that the list of albums already loads when the page loads, so the user don’t have to click on a button first.
But Sayontan, don’t do it if it’s hard to make or it will take you much time. Your plugin is already very nice and sure I will find a solution on my and (for example to give the photographer edit_post capability) without that extra functionality.
Peter
Don’t worry about it – it is not a big deal and I can have it ready by the middle of the week.
That sounds awesome!
I bought you a coffee to make developing more comfortable! ??
Hi Sayontan:
Firstly, congrats on a marvelous plugin. I am very impressed.
I wanted to join the discussion because I have been trying to figure out how to use the album id provided by Google Photos to speed up the process of adding albums to my word press pages. The album selector that you have provided only list the most recent “X” albums. Good for recent albums, bad for really old ones.
In my case, my first updates were easy, as the albums were all within the last couple years. But as I am go back farther in time, I find that I need to click “More” about 10 times or so. This is a long and slow process. I am willing to edit the html, and was expecting to be able to cut and paste an existing shortcoe, then replace the album id with a different one. But this doesn’t seem to be the case.
Any ideas? Or other solutions? For example, if I could select a time range for album selection?
And thanks again for Photonic. I am stilled thrilled.
@warrenlong,
What about the Helper page (Photonic → Helpers)? This could be a typical workflow:- Open the Helpers page on one tab of your browser.
- In the “Google Photos” section of the helpers keep clicking “More” till you have reached the end of the album listing. The helpers present a listing of album names, a single thumbnail per album and the id.
- You could simply copy over all of this information out to a separate place and generate your shortcodes from it. I typically copy-paste into Excel and then apply concatenation functions to build out my shortcode – it takes under a few minutes to do so (that might have something to do with my familiarity with Excel, but it is not a difficult task).
- Alternatively you can simply use the listing on the Helpers page as a reference and copy-paste your shortcodes. Note that you can still have the builder generate shortcodes if you are using the Classic Editor. You could have one shortcode generated, then copy-paste it and swap out the album ids. You could also paste the shortcode into a “shortcode block” instead of creating a Photonic block from scratch.
There is a long story behind why I cannot build in a “Show All” type of function, but if I were to summarize it in 3 words, this is it: API quota limits.
If you look at Photonic’s reviews, I have only received 4 reviews of 1-star in the past 2 years, and 3 of them have something to do with the setup being too complicated (in spite of my copious documentation and almost instantaneous support). The culprit in all of these cases is the labyrinthine route to get a Google Client ID. The only harder process is for Instagram, where it would rather be preferable to have a root canal treatment on all of one’s teeth – luckily the users don’t have to go through that.
I could have saved myself some grief by bundling my own Google Client ID, but that is where the API quota limits kick in. Google currently caps the number of Google Photos API calls associated with each application at 10,000 per day. Up to September 2018 this was 2,500. This means that if I have 500 users using Photonic for Google Photos (I have at least twice that many since Photonic has 10,000 users), each person has a single gallery, and that page is visited 20 times in a day, the next visit will trigger an error.
Now, Google’s API does not allow searching by album name, and it does not allow listing of more than 50 albums in one shot. Since the API doesn’t allow searching, I essentially have to fetch all albums and then run through the search by checking each album individually. And since I cannot get more than 50 albums in one shot, I have to make all these calls behind the scenes – so if you have 500 albums, I will have to make 10 calls (sequentially, because the only way to retrieve the next set is via a token returned in a previous set), and then parse through each result. This is not only processor intensive, but also it takes up 9 additional calls.
Compound this with, say, a shortcode to display (or search through) all 500 albums on the front-end. Even if your page has just 20 visits a day, you are automatically looking at 200 calls! And if you have more instances of shortcodes the numbers just keep blowing up.
Even without my putting in my own client ID users run a risk of eating through their API quota limits with this type of a solution. At least with what I have in place, automatic calls are not triggered – only if a user doesn’t find something does he or she request for more data.
So:
- Google’s API offers limited search capabilities …
- … Resulting in a requirement to fetch all data to search effectively …
- … But data can only be fetched in small packet sizes – maximum 50 albums / 100 photos in one shot …
- … And the results are short-lived URLs, meaning they cannot be cached to avoid extra calls!!
I am working with Google to get my API quota limit bumped up, but even if that happens and I start bundling my client id (simplifying the setup process), I wouldn’t be putting in an auto-fetch solution, as that will almost certainly violate Google’s terms and conditions.
Hi @warrenlong,
I have 100+ albums to “convert” from Picasa to Google Photos (GP) with the new shortcode.
Maybe it will help you if I share with you how I did it. Because I do not have much time (I’m traveling by train to work and typing with my iPhone), I tell you the “short version”. If you like, I can tell you more details later (tomorrow).
I used the plugins Advanced Custom Fields (ACF), WP all export, WP all import, Custom Content Shortcode and of course Excel.
1. I created a custom field “album_id” and added for one album the ID in that field.
2. I made an export of all my albums (I have a custom post type “albums”) with the fields ID, title, date, album_id and content. Then open it in Excel.
3. I loaded the full list of albums at the helper page, selected the whole table and made a copy to Word (Excel doesn’t recognize it as table, Word will) and select the table and made a copy to a new worksheet at the file you have open.
4. In the column album_id I added a formula with the VLOOKUP function to find a match between the date in the export and the first 8 characters of the album title in GP. Lucky for me, I started the album name always with the date of the event (format 20190124) and the date of the album in WP also the date of the event and I never had 2 events at the same date.
I filled the the whole column with the formula so every the correct album id.
5. In the content column I removed the old shortcode (not the <p> around it). Lucky for me in most cases the shortcode was the only content in the field. Then I saved it as xlsx.
6. Then I saved the exported worksheet (with now the album id) as csv and removed the columns except the (post) id, album_id and content and saved it.
7. I made an import to WP.
8. In the single post template I pass the album_id to the shortcode (below the content).
I hope It will help you.
Peter
I wanted to provide an update on the status of this.
I have finished my development activities here for the “helper” shortcode some time back, but I am waiting for Google to respond on a different topic. Basically I am waiting for them to clear my API key for a higher quota so that I may radically simplify the authentication process. Once I manage to get that sorted out with Google I will release this version.
Hi Sayontan,
Thank you for the update! I’m not in a hurry. Every improvement is appreciated.
In case Google will give you a higher quota, will it still be possible for the users to use there own Client ID (so you will give the choice to use yours or there own)?
Peter
In case Google will give you a higher quota, will it still be possible for the users to use there own Client ID (so you will give the choice to use yours or there own)?
Yes, users will be able to use their own client ID. If they have already gone through the authentication process I will not be interfering with that. For new users the default will be using what I bundle, but they can choose to use their own too.
Nice! That will make it much easier to set up for the average user. I look forward to it with curiosity!
Enjoy the last part of your weekend!
@sayontan ?? The information in the Helpers page is PERFECT. Thank you, thank you, thank you. Just what I needed. And I am also stunned at the amount of support you are providing to everyone. Congrats. How do I buy you a coffee? Or 2? ??
@peterpolow: Thank you for the unbelievably complete description of how to convert my Picasa albums to Google photos albums. I am very lucky not to be in your position. I never really embraced the Picasa albums, and pretty much all of my albums are true Google photos ones.
Once again, I am thrilled with this plugin. I am going to continue updating my word press pages using the Helpers page. I am kind of embarrassed to have not poked around more before asking my question.
Peter,
An update here: I added thephotonic_helper
shortcode for the functionality above in version 2.19.You should be able to use this shortcode on a page on the front-end thus:
[photonic_helper type='google']
It should print the albums in a tabular form.
- The topic ‘Get album ID from Google Photos outside Helper page’ is closed to new replies.