-
Notifications
You must be signed in to change notification settings - Fork 4
/
social_media_size.R
67 lines (63 loc) · 1.98 KB
/
social_media_size.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#' Social Media Image Sizes
#'
#' A convenience function for getting recommended dimensions for images on social media sites.
#'
#' Twitter:
#'
#' link: Image from a Tweet with shared link
#' one: Tweet sharing a single image (default)
#' two: Tweet sharing two images
#' three_left: Tweet sharing three images, Left image
#' three_tight Tweet sharing three images, Right images
#' four: Tweet sharing four images
#'
#' Instagram:
#'
#' feed_large: (default)
#' feed_small:
#' stories_large:
#' stories_small:
#'
#' @param platform currently only "twitter"
#' @param type which type of image
#'
#' @return named vector of width and height in pixels
#' @export
#'
#' @examples
#' social_media_size("twitter", "link")
#' social_media_size("twitter", "one")
#' social_media_size("twitter", "two")
#'
social_media_size <- function(platform = c("twitter", "instagram"),
type = "default") {
# https://sproutsocial.com/insights/social-media-image-sizes-guide/
if (match.arg(platform) == "twitter") {
size <- switch(type,
# Image from a Tweet with shared link:
link = c(1200, 628),
# Tweet sharing a single image:
one = c(1200, 675),
# Tweet sharing two images:
two = c(700, 800),
# Tweet sharing three images:
# Left image:
three_left = c(700, 800),
# Right images:
three_right = c(1200, 686),
# Tweet sharing four images:
four = c(1200, 600),
c(1200, 675)
)
} else if (match.arg(platform) == "instagram") {
size <- switch(type,
feed_large = c(1080, 1080),
feed_small = c(612, 612),
stories_large = c(1080, 1920),
stories_small = c(600, 1067),
c(1080, 1080)
)
}
names(size) <- c("width", "height")
size
}