| 1484 | |
| 1485 | /** |
| 1486 | * @ticket 36084 |
| 1487 | */ |
| 1488 | function test_get_image_send_to_editor_defaults() { |
| 1489 | $id = self::$large_id; |
| 1490 | $caption = ''; |
| 1491 | $title = 'A test title value.'; |
| 1492 | $align = 'left'; |
| 1493 | |
| 1494 | // Calculate attachment data (default is medium). |
| 1495 | $attachment = wp_get_attachment_image_src( $id, 'medium' ); |
| 1496 | |
| 1497 | $html = '<img src="%1$s" alt="" width="%2$d" height="%3$d" class="align%4$s size-medium wp-image-%5$d" />'; |
| 1498 | $expected = sprintf( $html, $attachment[0], $attachment[1], $attachment[2], $align, $id ); |
| 1499 | |
| 1500 | $this->assertSame( $expected, get_image_send_to_editor( $id, $caption, $title, $align ) ); |
| 1501 | |
| 1502 | $this->assertSame( $expected, get_image_send_to_editor( $id, $caption, $title, $align ) ); |
| 1503 | } |
| 1504 | |
| 1505 | /** |
| 1506 | * @ticket 36084 |
| 1507 | */ |
| 1508 | function test_get_image_send_to_editor_defaults_with_optional_params() { |
| 1509 | $id = self::$large_id; |
| 1510 | $caption = 'A test caption.'; |
| 1511 | $title = 'A test title value.'; |
| 1512 | $align = 'left'; |
| 1513 | $url = get_permalink( $id ); |
| 1514 | $rel = 'nofollow'; |
| 1515 | $size = 'thumbnail'; |
| 1516 | $alt = 'An example alt value.'; |
| 1517 | |
| 1518 | // Calculate attachment data. |
| 1519 | $attachment = wp_get_attachment_image_src( $id, $size ); |
| 1520 | |
| 1521 | $html = '<a href="%1$s" rel="%2$s"><img src="%3$s" alt="%4$s" width="%5$d" height="%6$d" class="size-%8$s wp-image-%9$d" /></a>'; |
| 1522 | $html = '[caption id="attachment_%9$d" align="align%7$s" width="%5$d"]' . $html . ' %10$s[/caption]'; |
| 1523 | |
| 1524 | $expected = sprintf( $html, $url, $rel, $attachment[0], $alt, $attachment[1], $attachment[2], $align, $size, $id, $caption ); |
| 1525 | |
| 1526 | $this->assertSame( $expected, get_image_send_to_editor( $id, $caption, $title, $align, $url, $rel, $size, $alt ) ); |
| 1527 | } |
| 1528 | |
| 1529 | /** |
| 1530 | * @ticket 36084 |
| 1531 | */ |
| 1532 | function test_get_image_send_to_editor_defaults_no_caption_no_rel() { |
| 1533 | $id = self::$large_id; |
| 1534 | $caption = ''; |
| 1535 | $title = 'A test title value.'; |
| 1536 | $align = 'left'; |
| 1537 | $url = get_permalink( $id ); |
| 1538 | $rel = ''; |
| 1539 | $size = 'thumbnail'; |
| 1540 | $alt = 'An example alt value.'; |
| 1541 | |
| 1542 | // Calculate attachment data. |
| 1543 | $attachment = wp_get_attachment_image_src( $id, $size ); |
| 1544 | |
| 1545 | $html = '<a href="%1$s"><img src="%2$s" alt="%3$s" width="%4$d" height="%5$d" class="align%6$s size-%7$s wp-image-%8$d" /></a>'; |
| 1546 | |
| 1547 | $expected = sprintf( $html, $url, $attachment[0], $alt, $attachment[1], $attachment[2], $align, $size, $id ); |
| 1548 | |
| 1549 | $this->assertSame( $expected, get_image_send_to_editor( $id, $caption, $title, $align, $url, $rel, $size, $alt ) ); |
| 1550 | } |