| @@ -119,9 +119,9 @@ | ||
| 119 | 119 | if ( ! empty( $template['layers'] ) ) { |
| 120 | 120 | $poster = self::append_layers( $poster, $template['layers'] ); |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - if ( null === $path ) { | |
| 123 | + if ( is_null( $path ) ) { | |
| 124 | 124 | return $poster->show( Config::get_file_format(), Config::get_quality() ); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | $poster->save( $path, Config::get_quality() ); |
| @@ -236,8 +236,24 @@ | ||
| 236 | 236 | if ( isset( $fieldset[ $key ] ) ) { |
| 237 | 237 | $layer['content'] = $fieldset[ $key ]; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | + if ( isset( $layer['textconvert'] ) && 'default' !== $layer['textconvert'] ) { | |
| 241 | + if ( 'uppercase' === $layer['textconvert'] ) { | |
| 242 | + if ( function_exists( 'mb_strtoupper' ) ) { | |
| 243 | + $layer['content'] = mb_strtoupper( $layer['content'] ); | |
| 244 | + } else { | |
| 245 | + $layer['content'] = strtoupper( $layer['content'] ); | |
| 246 | + } | |
| 247 | + } elseif ( 'lowercase' === $layer['textconvert'] ) { | |
| 248 | + if ( function_exists( 'mb_strtolower' ) ) { | |
| 249 | + $layer['content'] = mb_strtolower( $layer['content'] ); | |
| 250 | + } else { | |
| 251 | + $layer['content'] = strtolower( $layer['content'] ); | |
| 252 | + } | |
| 253 | + } | |
| 254 | + } | |
| 255 | + | |
| 240 | 256 | return $layer; |
| 241 | 257 | } |
| 242 | 258 | |
| 243 | 259 | /** |
| @@ -293,13 +309,13 @@ | ||
| 293 | 309 | $args['outline'] = true; |
| 294 | 310 | } |
| 295 | 311 | |
| 296 | 312 | if ( ! isset( $layer['width'] ) ) { |
| 297 | - $layer['width'] = 0; | |
| 313 | + $layer['width'] = 1; | |
| 298 | 314 | } |
| 299 | 315 | |
| 300 | 316 | if ( ! isset( $layer['height'] ) ) { |
| 301 | - $layer['height'] = 0; | |
| 317 | + $layer['height'] = 1; | |
| 302 | 318 | } |
| 303 | 319 | |
| 304 | 320 | // Update layer position and dimensions. |
| 305 | 321 | $layer = self::update_layer_position( $layer, $boundary ); |
| @@ -335,13 +351,19 @@ | ||
| 335 | 351 | // Update layer position and dimensions. |
| 336 | 352 | $layer = self::update_layer_position( $layer, $boundary ); |
| 337 | 353 | $layer = self::update_layer_dimensions( $layer, $poster ); |
| 338 | 354 | |
| 339 | - // Prepare common layer args. | |
| 340 | - $args = self::prepare_args( $layer, array( 'x', 'y' ) ); | |
| 355 | + $args = self::prepare_args( $layer, array( 'x', 'y', 'opacity' ) ); | |
| 341 | 356 | |
| 357 | + // Try to get file from attachment id. | |
| 358 | + $file = get_attached_file( $layer['attachment'] ); | |
| 359 | + | |
| 360 | + if ( empty( $file ) ) { | |
| 361 | + return $poster; | |
| 362 | + } | |
| 363 | + | |
| 342 | 364 | // Create new editor instance by attachment id. |
| 343 | - $attachment = $image->make( get_attached_file( $layer['attachment'] ) ); | |
| 365 | + $attachment = $image->make( $file ); | |
| 344 | 366 | |
| 345 | 367 | return $poster->insert( self::resize_attachment( $attachment, $layer ), $args, $boundary ); |
| 346 | 368 | } |
| 347 | 369 | |
| @@ -534,17 +556,25 @@ | ||
| 534 | 556 | * |
| 535 | 557 | * @return array List of layer settings. |
| 536 | 558 | */ |
| 537 | 559 | private static function update_layer_dimensions( $layer, $poster ) { |
| 560 | + if ( ! isset( $layer['width'] ) ) { | |
| 561 | + $layer['width'] = 0; | |
| 562 | + } | |
| 563 | + | |
| 564 | + if ( ! isset( $layer['height'] ) ) { | |
| 565 | + $layer['height'] = 0; | |
| 566 | + } | |
| 567 | + | |
| 538 | 568 | $width = absint( $poster->width() ); |
| 539 | 569 | |
| 540 | - if ( $layer['width'] < 0 ) { | |
| 570 | + if ( $layer['width'] <= 0 ) { | |
| 541 | 571 | $layer['width'] = $width + $layer['width'] - $layer['x']; |
| 542 | 572 | } |
| 543 | 573 | |
| 544 | 574 | $height = absint( $poster->height() ); |
| 545 | 575 | |
| 546 | - if ( $layer['height'] < 0 ) { | |
| 576 | + if ( $layer['height'] <= 0 ) { | |
| 547 | 577 | $layer['height'] = $height + $layer['height'] - $layer['y']; |
| 548 | 578 | } |
| 549 | 579 | |
| 550 | 580 | return $layer; |