ckgdesign Posted September 25, 2014 Posted September 25, 2014 (edited) 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 September 25, 2014 by ckgdesign
jdfwarrior Posted September 25, 2014 Posted September 25, 2014 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?
ckgdesign Posted September 25, 2014 Author Posted September 25, 2014 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.
Vero Posted September 26, 2014 Posted September 26, 2014 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
ckgdesign Posted September 28, 2014 Author Posted September 28, 2014 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.
jdfwarrior Posted September 29, 2014 Posted September 29, 2014 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.
rjames86 Posted September 29, 2014 Posted September 29, 2014 (edited) 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 September 29, 2014 by Ryan M
rjames86 Posted September 29, 2014 Posted September 29, 2014 (edited) Also more generally, there is so much that you can do with Alfred. Don't base your purchase decision on whether it can do this one thing. For the most part, if you can write a script to do something, it can be done in Alfred. Edited September 29, 2014 by Ryan M
ckgdesign Posted September 29, 2014 Author Posted September 29, 2014 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.
rjames86 Posted September 30, 2014 Posted September 30, 2014 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! ckgdesign 1
ckgdesign Posted September 30, 2014 Author Posted September 30, 2014 (edited) 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 September 30, 2014 by ckgdesign
rjames86 Posted September 30, 2014 Posted September 30, 2014 Completely off topic. Are you from Ireland? I've only heard "legend" while I lived there Something must not be working. I had that happen as well, and there was a bug in the code. Can you click on the debug button in the workflow and let me know what it prints out?
ckgdesign Posted September 30, 2014 Author Posted September 30, 2014 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.
rjames86 Posted September 30, 2014 Posted September 30, 2014 ahh close enough Easy fix. Re-download the workflow and you should be set ckgdesign 1
ckgdesign Posted September 30, 2014 Author Posted September 30, 2014 Aha! Fantastic. That works fine. Thank you very much for your help Ryan! rjames86 1
rjames86 Posted September 30, 2014 Posted September 30, 2014 You're very welcome! Glad it worked out. I might actually end up using this one as well.
ckgdesign Posted September 30, 2014 Author Posted September 30, 2014 Yeah, I think it'll come in handy for many people. The system I was using previously was to upload the images to Photobucket every single time, purely for the image code, so I'm hoping this'll chop out that element.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now