Jump to content

Dropbox IMG Tags


Recommended Posts

Hi all,

 

I just discovered Alfred around, lets say, 20 minutes ago. I really don't know much about it at all.

 

What I'd like to achieve is the following, but I'm not sure if it's possible.

 

Lets say I have a folder of images which I then upload to Dropbox. What I'd like it to do is generate Dropbox IMG tags surrounding all the images for that album and copy it to the clipboard. So, I can then go onto the web and paste the links.

 

Or, even just to select the images I want to post, and have it generate the IMG tags for me (instead of the entire album.

 

Am I way off the mark, or is this possible?

 

Thanks!

Edited by ckgdesign
Link to comment

Hi all,

 

I just discovered Alfred around, lets say, 20 minutes ago. I really don't know much about it at all.

 

What I'd like to achieve is the following, but I'm not sure if it's possible.

 

Lets say I have a folder of images which I then upload to Dropbox. What I'd like it to do is generate Dropbox IMG tags surrounding all the images for that album and copy it to the clipboard. So, I can then go onto the web and paste the links.

 

Or, even just to select the images I want to post, and have it generate the IMG tags for me (instead of the entire album.

 

Am I way off the mark, or is this possible?

 

Thanks!

 

So you're just looking to be able to apply tags (OSX tags) to the images?

Link to comment

So you're just looking to be able to apply tags (OSX tags) to the images?

Hey David,

 

What I want to do is upload the images to dropbox (in a Finder window) and then once an album or group if images is uploaded, it will generatre a list of [ IMG] tags (markup) for each image uploaded. So, from that point I can paste from the clipboard the IMG tags onto a forum (eg here).

 

Hope that makes a bit more sense. I don't want to add the OSX coloured tags. This is purely a copy image source and generate IMG tags for all those images.

Link to comment

Hey David,

 

What I want to do is upload the images to dropbox (in a Finder window) and then once an album or group if images is uploaded, it will generatre a list of [ IMG] tags (markup) for each image uploaded. So, from that point I can paste from the clipboard the IMG tags onto a forum (eg here).

 

Hope that makes a bit more sense. I don't want to add the OSX coloured tags. This is purely a copy image source and generate IMG tags for all those images.

 

If you are a Powerpack user, could you please fill in your registered Powerpack address in your forum profile? Thanks :)

Link to comment

I am not a Powerpack user. I'm definitely considering buying it, but if the above functionality can't be done, then I'm not sure I'll have any use for it.

 

OHHH gotcha. When you said IMG tags I didn't catch that you meant markup. The only portion of this that I'm wondering about it getting the links for the files uploaded to dropbox. I THINK it can be done. Generating the markup would be super easy. I just need to look into generating the links. I'm going to reach out to someone and report back later.

Link to comment

This is certainly possible. What I imagine is you would use the file buffer (or select a single file), and run a file action to get the img tags. It would probably need to look something like this (pseudocode style)

from dropbox import client

dbclient = client.DropboxClient(access_token)

def ensure_in_dropbox(file): 
    return True if in Dropbox else False 

def get_shared_link(file): 
    link = dbclient.share(file) 
    # This is to generate the true url, not a preview 
    return link['url'].replace('www.dropbox', 'dl.dropboxusercontent') 


img_links = [] 

for file in files: 
    if ensure_in_dropbox(file): 
        img_links.append( '<img src="{}"></img>'.format(get_shared_link(file)) ) 

print "\n".join(img_links)

 

You would then pass that one to a "Copy to Clipboard" action

Edited by Ryan M
Link to comment

Hey Ryan,

 

Thanks for that. I made the purchase of Alfred, but I can't code/script very well at all.

 

What I've done, is setup this, which I'm hoping is on the right track: http://cl.ly/image/2C0p0b3p2A3T

 

1. I want to select the files in dropbox by opening finder and selecting the files.

2. Make myself a hotkey which performs the action.

3. Action

4. Code copies to clipboard

5. I can then paste the text.

 

Is what I'm doing correct?

 

I appreciate the code above, but it's pseudocode like you mentioned. I'm not sure how to translate that into real script.

Link to comment

Yep, you're on the right track.

 

Give this workflow a try:

 

https://www.dropbox.com/s/s1462ddsq0cy1f0/Dropbox%20Images%20to%20img%20tags.alfredworkflow?dl=0

 

You'll need to first go to https://www.dropbox.com/developers, create a new app using the Sync API, with access to all files in your account. Once you've done that, click the link that says "generate access token". You'll need to put this in the alfred workflow script where it says `access_token = ''`. Put it between the quotes.

 

Hope this helps!

Link to comment

Legend, thanks Ryan!

 

All of that was OK. I made the app with Sync API and included my access_token in your script. However, the copy to clipboard text isn't the entire URL of the image (or the [ IMG] tags), it just spits out the names of the files themselves like:

 

IMG_0001.jpg

IMG_0002.jpg

IMG_0003.jpg

etc.

 

So it isn't wrapping in image tags or displaying the URL of the images.

 

With your workflow, I get the 'Got links!' notification, so that element works.

Edited by ckgdesign
Link to comment

From Australia, Ryan. :)

 

Here's the error I get in debug mode:

 

[ERROR: alfred.workflow.action.script] Code 1: Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "dropbox/__init__.py", line 3, in <module>
    from . import client, rest, session
  File "dropbox/client.py", line 22, in <module>
    from .rest import ErrorResponse, RESTClient
  File "dropbox/rest.py", line 21, in <module>
    raise ImportError('Dropbox python client requires urllib3.')
ImportError: Dropbox python client requires urllib3.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...