feat(twitter): add option to number the medias (#19050)
* feat(twitter): add number to the media * (feat/twitter): add option `mediaNumber` to number the medias in tweets --------
This commit is contained in:
parent
d929c7a15c
commit
c150211749
|
|
@ -29,6 +29,7 @@ export const namespace: Namespace = {
|
|||
| \`forceWebApi\` | Force using Web API even if Developer API is configured, only available in \`/twitter/user\` and \`/twitter/keyword\` | \`0\`/\`1\`/\`true\`/\`false\` | \`false\` |
|
||||
| \`count\` | \`count\` parameter passed to Twitter API, only available in \`/twitter/user\` | Unspecified/Integer | Unspecified |
|
||||
| \`onlyMedia\` | Only get tweets with a media | \`0\`/\`1\`/\`true\`/\`false\` | \`false\` |
|
||||
| \`mediaNumber \` | Number the medias | \`0\`/\`1\`/\`true\`/\`false\` | \`false\` |
|
||||
|
||||
Specify different option values than default values to improve readability. The URL
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => {
|
|||
heightOfPics: fallback(params.heightOfPics, queryToInteger(routeParams.get('heightOfPics')), -1),
|
||||
sizeOfAuthorAvatar: fallback(params.sizeOfAuthorAvatar, queryToInteger(routeParams.get('sizeOfAuthorAvatar')), 48),
|
||||
sizeOfQuotedAuthorAvatar: fallback(params.sizeOfQuotedAuthorAvatar, queryToInteger(routeParams.get('sizeOfQuotedAuthorAvatar')), 24),
|
||||
mediaNumber: fallback(params.mediaNumber, queryToInteger(routeParams.get('mediaNumber')), false),
|
||||
};
|
||||
|
||||
params = mergedParams;
|
||||
|
|
@ -85,7 +86,7 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => {
|
|||
addLinkForPics,
|
||||
showTimestampInDescription,
|
||||
showQuotedInTitle,
|
||||
|
||||
mediaNumber,
|
||||
widthOfPics,
|
||||
heightOfPics,
|
||||
sizeOfAuthorAvatar,
|
||||
|
|
@ -116,6 +117,8 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => {
|
|||
const formatMedia = (item) => {
|
||||
let img = '';
|
||||
if (item.extended_entities) {
|
||||
const mediaCount = item.extended_entities.media.length;
|
||||
let index = 1;
|
||||
for (const media of item.extended_entities.media) {
|
||||
// https://developer.x.com/en/docs/tweets/data-dictionary/overview/extended-entities-object
|
||||
let content = '';
|
||||
|
|
@ -156,6 +159,11 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => {
|
|||
}
|
||||
|
||||
img += content;
|
||||
|
||||
if (mediaNumber) {
|
||||
img += `<p style="text-align:center">${index}/${mediaCount}</p>`;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue