Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I've had to write a patch to support displaying of tweets images in a view. The patch provides a new views field "Photo 1" and some new checkboxes in settings for the message text views field:
- Replace urls with their long version
- Remove media urls
The latter is intended to remove the URL to the photo in a tweet if adding the photo tio the view.
If it's useful I'll have a look at reproducing it in 7.x branch.
Comment | File | Size | Author |
---|---|---|---|
#38 | twitter-tweet-photos-d7-1936598-37.patch | 5.82 KB | kevineinarsson |
#24 | twitter-n1936598-24-7.x-5.x.png | 160.1 KB | DamienMcKenna |
#9 | twitter-tweet-photos-d7-1936598-9.patch | 4.19 KB | recrit |
#5 | twitter-tweet-photos-d7-1936598-5.patch | 4.25 KB | recrit |
#3 | twitter_tweet_photos-1936598-3.patch | 99.38 KB | hughworm |
Comments
Comment #1
hughworm CreditAttribution: hughworm commentedComment #2
hughworm CreditAttribution: hughworm commentedYou can see it in action in all it's glory at www.gethooked.co.uk.
Comment #3
hughworm CreditAttribution: hughworm commentedRevised patch.
Comment #4
Yorgg CreditAttribution: Yorgg commentedCan you help port this to the 7.x branch?
Comment #5
recrit CreditAttribution: recrit commentedThe attached patch is applied to 7.x-5.x. It only addresses storage and loading of the entities.
The patch adds the following:
* entities field to the twitter table
* views field handler for the first image attached to the tweet
* updates to loading and saving tweets to serialize and unserialize
Comment #6
juampynr CreditAttribution: juampynr commentedWe could just do if (!empty($row->entities) && (is_string($row->entities)) {
Misssing &$sandbox argument here.
Why could it be an object or a string? Shouldn't it always be just a string to be deserialized?
If we use !empty() instead of isset() we also check that the array contains values.
Comment #7
juampynr CreditAttribution: juampynr commentedReopening.
Comment #8
recrit CreditAttribution: recrit commentedI can re-roll with:
* Update function adding &$sandbox,
* Simplifying with !empty()
The is_object() check was in case it was already unserialized. The thinking was more of a handler like the entity field hander where the object would be loaded upfront with twitter_status_load(). Since this is not the case this check could be removed.
Comment #9
recrit CreditAttribution: recrit commentedupdated patch per requests in #6 and applied to the latest 7.x-5.x.
Comment #10
juampynr CreditAttribution: juampynr commentedIs this correct? I did not know that fetchObject() would return an "entities" property.
Why "first" ?
Comment #11
juampynr CreditAttribution: juampynr commentedBased on https://support.twitter.com/articles/20156423-posting-photos-on-twitter, only one photo can be uploaded to Twitter.
Comment #12
juampynr CreditAttribution: juampynr commentedMade the following changes and committed it:
http://drupalcode.org/project/twitter.git/commit/3bac2d7
Thanks!
Comment #14
capellicSorry if reopening this issue is the wrong course of action. I just downloaded "7.x-5.x-dev", ran update.php, and saw the the Image field appear as an option. Problem is that the image doesn't display at all -- only the empty DIV wrappers. Also, I can't select the Image field as a conditional. (I want to only show tweets that have a photo.) Am I downloading the right version? Thanks.
Comment #15
Baysaa CreditAttribution: Baysaa commented@capellic I've got same issue with the 7.x-5.x-dev version. However go to the commit log at #12 and you can see the diff there. Copy it, make it into a patch and apply it to 7.x-5.8 and run update.php and it works.
Comment #16
recrit CreditAttribution: recrit commented@juampy: Regarding "first image", Twitter allows up to 4 images to be uploaded per articlet that referenced: https://support.twitter.com/articles/20156423-posting-photos-on-twitter.
A possible improvement would to update the help text to state "The first image attached to the tweet.".
Comment #17
Dr Trichome CreditAttribution: Dr Trichome commented@baysaa I successfully applied the patch to 7.x-5.8, ran drush updb, enabled the twitter:image in views, and ran cron. I can see an empty label (image:), but still no images are being pulled in from twitter. I have "formatted tweet" enabled in views, and everything else is there, just not the image associated with the tweet. What should I try next?
Comment #18
DamienMcKennaNeeds to be ported to the 7.x-6.x branch.
Comment #19
DamienMcKennaComment #20
Danny EnglanderI am experiencing the same issue as #14 & #17 above, an image label but no image. (also ran drush updb successfully). This is from the latest dev 5.x. I have a native twitter image uploaded to Twitter and rendered using their image service. I am not sure I understand the comment in #15, make a patch to apply to something that's already been committed to dev on top of that? In my local git, I see all the changes in dev that were in the patch.
Comment #21
erald CreditAttribution: erald commentedI have the same issue applied the patch from #12 ran update deleted the account readied it and pulled again via cron but no images there.
Added the twitter image to the view
>> never mind I had to activate the mentions it is working perfectly
sorry for the spamming
Comment #22
DamienMcKennaLets go back to 7.x-5.x and fix it, then see about porting it to 7.x-6.x and 6.x-5.x.
Comment #23
DamienMcKennaComment #24
DamienMcKennaImages are working ok for me with the current 7.x-5.x-dev release:
Comment #25
DamienMcKennaThe images are not being displayed in the 6.x-5.x branch, and I don't have an installation of the 7.x-6.x branch - anyone able to confirm the problem?
Comment #26
DamienMcKennaYes, so the 'entities' system needs to be ported to both the 6.x-5.x and 7.x-6.x branches. There's also an 'extended_entities' structure in the tweet JSON object, it may be worthwhile storing that too, just to have it, which would then also need to be ported to 7.x-5.x.
Comment #27
DamienMcKennaTaking this off the rota for the next releases.
Comment #28
DamienMcKennaComment #29
tescometro CreditAttribution: tescometro commentedApologies if, but did this get added to any release for 6.x ? Or is it planned to?
Thanks for the module (using 6.x 5.3), working well, just the images would be extra nice!
Comment #30
DamienMcKenna@tescometro: No, sorry, the functionality needs to be backported to 6.x-5.x.
Comment #31
homebrewruss CreditAttribution: homebrewruss commentedFor anyone one using the latest 7.x-5.x dev version but struggling to get images to display. Make sure you uninstall any versions of the Twitter module you already have installed from the database before re-installing the latest dev version.
Images should then work fine.
Comment #32
DamienMcKenna@homebrewruss: You shouldn't have to uninstall to make it work - if anyone's having a problem getting it to work then please open an issue and I'll see if I can help fix the problem.
Comment #33
DamienMcKennaThis needs to be ported.
Comment #34
kevineinarsson CreditAttribution: kevineinarsson at Websystem for ComplianceOnline Ltd commentedAttached is a patch ported for 7.x-6.x. Also updated the tweet template to show the field with hardcoded sizes (small image linked to large).
Comment #35
kevineinarsson CreditAttribution: kevineinarsson at Websystem for ComplianceOnline Ltd commentedGot an extra unserialize in there... fixed
Comment #36
kevineinarsson CreditAttribution: kevineinarsson at Websystem for ComplianceOnline Ltd commentedOk, I'm quite tired and I messed up again... forgot adding in another line. Next time I won't be lazy and actually check out the repo into the server on which I'm working and not have it on my local machine... :)
This patch also fixes an issue where arrays were being serialized twice while storing into the database.
Also removed the hard-linking of the tweet image to the full size image in the template. It seems unneccessary to force and can easily be added back in for those who want it.
Comment #38
kevineinarsson CreditAttribution: kevineinarsson at Websystem for ComplianceOnline Ltd commentedJeez... I had fat fingered a paranthesis in the last patch. This will hopefully be my last attempt at submitting the same patch. ;) Let's try this again.
Comment #39
kevineinarsson CreditAttribution: kevineinarsson at Websystem for ComplianceOnline Ltd commentedComment #40
Baysaa CreditAttribution: Baysaa as a volunteer commentedComment #41
DamienMcKenna