Is it possible to embed in Spreadsheets an image from a Google Photo (Google+ in GDrive) folder?
I have images in Google+ albums and with new functionality show them in Google Drive in location: My Drive/Google Photo .... I tried to show these images in Spreadsheets with:
=image("https://googledrive.com/host/FOLDERID/NAMEPHOTO.jpg")
but see nothing, no image, no errors just a blank cell.
What should I do?
In the major I want to organize (moving, upload etc.) and edit (rename) images in album on Google+ with function and google scripts for spreadsheet. So I try use new functionality - Google Photo Albums see in GDrive - to do this. And finally i need to show the images from albums Google+ (folder Google Photo in GDrive) in Spreadsheet Cells.
Google Drive hosting (googledrive.com/host/FOLDERID/...) is being deprecated. To properly embed an image on Google Drive, you need to follow the following steps:
In Google Drive, right click on an image and select either "Share..." or "Get Link"
You will get a link that looks either like:
drive.google.com/file/d/RaD0mNum3er/view?usp=sharing , or
drive.google.com/open?id=RaD0mNum3er
You need to convert the link to something like:
drive.google.com/uc?export=download&id=RaD0mNum3er
In your cell, enter =image("drive.google.com/uc?export=download&id=RaD0mNum3er")
To quicken the process, I'd create 3 new columns (let's say C, D, E).
C2 = drive.google.com/open?id=RaD0mNum3er
D2 = =REGEXEXTRACT(C2,"(?:(?:file/d/)|(?:open\?id=))(\w+)")
E2 = ="https://drive.google.com/uc?export=download&id="&E2
where
C is the link you got from Google Drive
D is the extracted file ID, and
E is the converted the permalink
Related
I am trying to reproduce a RSS reader like Feedly with Google Sheet and displaying with Glide as an app on my mobile phone.
Everything's fine with IMPORTFEED() function with titles, description, URL.
But it seems this function doesn't allow pictures to be displayed even if they are in the feed (which is not all the time).
So I am looking for a way to extract the main image from a blog post... the one displayed when you hover on a link in a Google Sheet cell.
I would like to get the link of that image displayed in the link preview and put that link in another cell.
Here is an example:
I tried IMAGE()
and also IMPORTXML when there is an image in the RSS feeds (but not all of them do... so I stopped)
Is it possible in Google Sheet to get the main image from the one displayed in the link preview ?
For instance, one of the blog I want to extract the main picture of a blog article would be Creajv (URL : https://creajv.com/ ; Feed : https://creajv.com/feed/)
So the IMPORTFEED() function I did in Google Sheets was :
=IMPORTFEED("https://creajv.com/feed/";"items";FALSE;3)
Which stands for :
=IMPORFEED(...) the function to import feeds from an URL
"items" the way to pull every data there is in the feed (you can use other parameters and can see all the possibilities on the GoogleFormulas documentation)
FALSE because I don't want the headers to be included
and the number 3 because I want only the last 3 results displayed.
And it displays perfectly : author, description, URL, date
But I did a little digging in Google and found that basically IMPORTFEED() cannot get images from feeds, even if it is added by the author of the blog (he has to add a feature to do it).
So I am now trying to see if there is another way which is not IMPORTFEED() to get every time the main image of a blog post.
And I saw Google Sheet is able to pull instantly it when I copy paste the URL of a blog article within a cell for instance for Creajv :
Print screen of the image I get when I click in the cell which contains the post URL
So my thoughts would be that I can pull the author, date, description etc. with IMPORTFEED (which works perfectly every time) and use a formula on the cell with the URL to get in another cell the URL of the picture pulled from the one in the link preview.
Two other possibilities might also be with Google App Script :
creating with the App Script a custom function
or creating a script pulling the image in a cell every time a new row is added via the IMPORTFEED() function.
Functions only, as Apps Script doesn't run on mobile Apps
How about this solution? I checked the website and inspected the image from the thumbnail.
Luckily, the structure is simple:
<div class="article-image">
<img src="https://creajv.com/wp-content/uploads/2020/11/HighresScreenshot00000.png" alt="Concours de Level Design avec Unreal Engine, du 11/11 au 05/12/2020">
</div>
You can get the url with IMPORTXML, and apply IMAGE to it:
=IMAGE(ImportXml("https://creajv.com/2020/11/08/concours-de-level-design-avec-unreal-engine/", "//div[#class='article-image']//img/#src"))
Since you are already retrieving the post url with your previous formula, change the source url by the correspondent cell:
=IMAGE(ImportXml(C1, "//div[#class='article-image']//img/#src"))
For example:
I need a way to insert an image into a specific cell in a specific Google Sheet. If there is any python package and/or slice of code that can accomplish this, please let me know. As far as I am aware Gspread does not have anything helpful.
You can simply insert an image from an URL with a formula like this:
'=image("https://drive.google.com/uc?export=view&id={}")'.format(file_id)
When you insert/upload the data be sure to choose USER_ENTERED for value input option. https://developers.google.com/sheets/api/reference/rest/v4/ValueInputOption
With gspred:
sheet_instance.insert_rows(rows, value_input_option='USER_ENTERED')
Overall to add image into Google Sheets can be accomplished with Python by first inserting the image file in Google Drive using the Google Drive API:
Here is how to insert it to google drive. - https://developers.google.com/drive/v2/reference/files/insert#examples,
and secondly linking to the image in Google Sheets with the Google Sheets API, Here is Google sheets API - https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#CellData
Note: Look under CellData
Today when experimenting with using importXML in Google Sheets, I ran into a problem. I was attempting to import the title header of a USTA Tournament page into the Google Sheet, however, this did not work as it just resulted in the HTML title of the webpage being displayed ('TournamentHome'). Below is the Google Sheet, and the website that is used:
Google Sheet and Function:
=importXML(F2, "//html//body[#id='thebody']//div[#id='content']//div[#id='pagetitle']")
Website and Section of Source Code Being Used
The title that I am trying to extract from the website is TOWPATH 24th ANNUAL THANKSGIVING JR SINGLES.
The link to the website is https://m.tennislink.usta.com/tournamenthome?T=225779
update:
=REGEXEXTRACT(QUERY(ARRAY_CONSTRAIN(IMPORTDATA(
"https://m.tennislink.usta.com/tournamenthome?T=225779"), 555, 1),
"where Col1 contains 'escape'"), "\(""(.*)""\)")
unfortunately, that won't be possible the way you trying because the field you attempt to scrape is controlled by JavaScript and Google Sheets can't understand/import JS. you can test this simply by disabling JS for a given link and you will see what exactly can be imported into Google Sheets:
How about this sample formula? In this formula, the title value is directly retrieved from the script before the value is put to #pagetitle. Please think of this as just one of several answers.
Sample formula:
=REGEXEXTRACT(IMPORTXML(A1,"//div[#class='tournament_search']/script"),"escape\(""([\w\s\S]+)""")
Result:
When https://m.tennislink.usta.com/TournamentHome/tournament.aspx?T=38079 and https://m.tennislink.usta.com/tournamenthome?T=225779 are put in "A1" and "A2", the results are as follows.
Reference:
REGEXEXTRACT
How is it possible to delete a slide from a Google Presentation using Google API?
In https://developers.google.com/slides/samples/slides it is said: The Slides API allows you to create, move, and delete slides. However, I'm unable to find how to do it.
You can use DeleteObjectRequest for tihs https://developers.google.com/slides/reference/rest/v1/presentations/request#DeleteObjectRequest
Pass your slide id to objectId.
In google app script you can do:
var presentation = SlidesApp.openById("23423423lksdjfsdlkfj");
var slides = presentation.getSlides();
slides[0].remove(); // Remove the first slide
You have to put the proper file id from the long part of the URL of the slide document.
First sorry if its a stupid guestion but im a really big beginner.
I would like to make an image gallyer similar to facebook, but what i dont really understand is te logic.
I made a multi image upload, it saves the image nam and extension to the database with a title .
A folder is created by the title name.
My problem is i dont know how to select them.
What i mean a person uploads 20 images in folder hello, on the page show the hello with one of the thumbnails and when i click it redirects me to the other pictures.
So tihs is the logic what i dont really understand, and i dont want anybody to write this for me, i only would like the opinion or a hint form a more expreienced developer.
Thank you
In your DB, keep track of the cover photo for each album. Since you probably want to allow users to name albums you might as well save that in there, too.
Table::albums
- id
- name
- photo_id //cover photo, or even the link to the image can be saved here directly if you don't like joins
- ...
Table::album_has_photos
- id
- album_id
- name
- url
- ...
To view the album overview: in your album controller extract the album names, cover photo links from table::albums and send those to the view;
In your view set up a link around each of the cover photos to a controller that loads the album contents from table::album_has_photos;
Display photos from one album and add visual effects.
Ooptional: add pagination to the album overview.
The best idea would be to keep the url of the images in the db (full url or relative - doesn't matter) and possibly the gallery id (if you're using more than one gallery). Then, you'd use the Database class to select all the image urls and send that data to the view. In the view, you can use a foreach loop to generate an appropriate tag for each of the selected images. After that, you could possibly add a lightbox plugin of some sort to have a nice popups when you click on thumbnails.