Download the PHP package evanshunt/lazy-focus-fit without Composer

On this page you can find all versions of the php package evanshunt/lazy-focus-fit. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package lazy-focus-fit

LazyFocusFit

A SilverStripe module with template methods to quickly make use of FocusPoint, LazySizes and object-fit.

Requirements

PHP

JS/CSS

Installation

composer require evanshunt/lazy-focus-fit

After installing this module, ensure front-end requirements are installed and properly initiated within your project.

Config values

If you wish to serve all images as WebP set the following in your yaml config.

Usage

This module adds 3 primary methods to SilverStripe Image objects, to allow quick creation of responsive image markup eather as <img> or <picture> tags or attributes which can be applied to any element for use as a background image.

Additional methods allow configuring the images to use object-fit, crop according to a specific aspect ratio, or add additional html attributes.

Note: Template parsing seems to have changed in Silverstripe 5, where previously it was not required to put an argument like 770 992px in quotes, it now appears to be required.

ResponsiveImg()

This method allows generating an <img> tag with a number of possible image sizes. On page load a 32px wide image will be loaded and the correct size will be lazyloaded using LazySizes auto-sizes functionality. A future version may allow explicitly defining a sizes attribute or using the browser's built in responsive sizing w/o LazySizes.

Example

ResponsivePicture()

This method generateds a <picture> element, and allows for more explicit art direction than ResponsiveImg(). You can define media query conditions under which your images will be shown. After the first classname argument, subsequent arguments should take the following format:

{ImageWidth}-{WidthDescriptor}-{PixelDensityDescriptor} {MinWidth}

Width and Pixel density descriptors are optional as defined here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/source#Attributes

MinWidth should be a screen width for a (min-width: xxx) media query, or 'default'. Start with largest width and work your way down to default.

Examples

ResponsiveBgAttributes

Requires Lazysizes bgSet plugin

This method generates html attributes, not an entire element, it is used to apply a background image. The arguments operate the same way as ResponsivePicture()

Be aware that this method generates class and style attributes so adding these to your template code will result in dublicated attributes.

Example

Helper methods

AddAttribute()

Adds additional attribute to the <picture> element generated by ResponsivePicture() or the <img> attribute generated by ResponsiveImg(). Must be called before the markup generating method.

Example

AddImgAttribute()

Adds additoinal attribute to the <img> element w/in the <picture> generated by ResponsivePicture(). Must be called before the markup generating method.

Example

AddAspectRatio()

Crops image to a specific proportion, centered on the FocusPoint, for use with ResponsivePicture() and ResponsiveImg(). Must be called before the markup generating method.

Example

ObjectFit()

Adds object-fit styles to style tag of ResponsivePicture() and ResponsiveImg(), also adds necessary data-attributes to work with objectFitPolyfill. Object position values come from FocusPoint.

By default object-fit: cover; is applied, but alternative values (fill, contain, scale-down) can be passed as an argument.

Examples

UseWebP()

If you haven't set the global config value to serve WebP, you can opt in for an individual image by calling this method. Must be called before the markup generating method.

Example


All versions of lazy-focus-fit with dependencies

PHP Build Version
Package Version
Requires jonom/focuspoint Version ^5
silverstripe/framework Version ^5
silverstripe/cms Version ^5
bigfork/silverstripe-webp-formatter Version ^1.0.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package evanshunt/lazy-focus-fit contains the following files

Loading the files please wait ....